# [Trigger]Is this an efficient Arc Formula?

#### Veronnis

Level 13
Hey guys, I'm making my own projectile system in GUI and I made something that works really well and handles any projectile I load into it, but I am curious if I made an efficient system or if it is trash compared to something else. Please peruse the below function that sets the pitch of the projectile travelling along the arc and let me know if you think it should be different, thanks! (Don't count leaks in the efficiency, I haven't de-leaked it yet.)

Note: PjcArc is a multiplier, when set at 1.00 the arc will appear as the upper half of a circle, when set to .5 it will appear as if the circle were only half as tall.

One more note: The pitch of the projectile is recalculated every .02 seconds, as is the DistanceLeft to travel.

• Arc
• Events
• Conditions
• Actions
• Set PjcArc[GenericLoopCount] = 1.00
• Set FullDistance[GenericLoopCount] = Distance between Start Cast and Target of Cast
• Special Effect - Set Pitch of ProjectileVisual[GenericLoopCount] to: (Radians(((-90.00 x PjcArc[GenericLoopCount]) + ((180.00 x ((FullDistance[GenericLoopCount] - DistanceLeft[GenericLoopCount]) / FullDistance[GenericLoopCount]

#### Pyrogasm

Level 36
In general, you want to avoid using Distance functions periodically as SquareRoot can be a costly function. It seems you are also repeatedly recalculating FullDistance here, and it could simply be done once at the start of the cast.

I see no issue with what you've done, but... projectile arcs in real life aren't circles, they're parabolas.

#### Veronnis

Level 13
Well the function that draws the arc is a parabolic function, which also uses square root :/ as for the distance function this projectile is homing so unfortunately it must update frequently in case the target moves. For distance between points is there anything that you imagine would do it more efficiently?

Replies
2
Views
385
Replies
2
Views
523
Replies
0
Views
2K
Replies
9
Views
1K
Replies
43
Views
12K