# [JASS]Calculating Arcs

#### emuman4evr

Level 4
Im currently developing a realistic arc system, basically it moves a unit from point a to point b in an arc. I need to use timers to do the loop thought but I have no idea how to use timers. So I need lots o help, heres the script:
JASS:
``````function PolarProjectionX takes real x, real dist, real angle returns real
endfunction
function PolarProjectionY takes real y, real dist, real angle returns real
endfunction
function ArcUnit takes unit u, real xA, real yA, real xB, real yB, real maxheight returns nothing
local real steps
local real halfpoint
local real PointAx
local real PointAy
local real dist
local real height = GetUnitFlyHeight(u)
local real angle = GetUnitFacing(u)
set PointAx = xA
set PointAy = yB
set dist = SquareRoot( (xB-PointAx)*(xB-PointAx)+(yB-PointAy)*(yB-PointAy))
set steps = dist/30
set halfpoint = dist/2
call SetUnitFacing(u, bj_RADTODEG * Atan2(yB - yA, xB - xA))
loop
exitwhen GetUnitX(u) == xB
exitwhen GetUnitY(u) == yB
set PointAx = PolarProjectionX( PointAx, steps, GetUnitFacing(u))
set PointAy = PolarProjectionY( PointAy, steps, GetUnitFacing(u))
if steps < halfpoint then
set height = height+20
call SetUnitFlyHeight(u,height,0)
set steps = steps-1
call SetUnitX(u, PointAx)
call SetUnitY(u, PointAy)
else
set height = height-20
call SetUnitFlyHeight(u,height,0)
call SetUnitX(u, PointAx)
call SetUnitY(u, PointAy)
set steps = steps-1
endif
endloop
endfunction``````

#### PurplePoot

Level 40
That could use a lot of optimizing, and it's a triangle, not an arc, currently.

As for the formula for an arc, if you want that, check this out.

As for timers, check this out.

#### emuman4evr

Level 4
That could use a lot of optimizing, and it's a triangle, not an arc, currently.

As for the formula for an arc, if you want that, check this out.

As for timers, check this out.

Thanks for those links, what do I use the Arc Calculation for? Do I just use it to set the max height or something?
I know it will resuly in a triangular arc, I made the mistake of deaccelerating the rate at which the unit move and should of decreased the height, Ill fix that.

#### PurplePoot

Level 40
The parabola function just needs a curve scale, a dist <that you're currently at>, and how far the parabola reaches.

#### emuman4evr

Level 4
So assuming im correct, I need to store the original distance between point a and point b (maxdist), and in the timer loop it recalculates with the current distance between the unit and point b (dist), and maxdist.

Level 40
Yes, that's it.

#### Waldbaer

Level 10
Well, I don't want to keep you from developing your own system, but if you just want to use it, you may find my Jump System useful, which does exactly what you are trying to do: moving a unit in a parabola from point a to point b.

Replies
4
Views
475
Replies
0
Views
362
Replies
10
Views
1K
Replies
2
Views
499
Replies
9
Views
507