• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Is this an efficient Arc Formula?

Status
Not open for further replies.
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]
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
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.
 
Status
Not open for further replies.
Top