• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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 45
Joined
Feb 27, 2007
Messages
5,578
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