• 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.

[Math] how do u make sinoid

Status
Not open for further replies.
Every 0.03 seconds, do the following:

You increment a real counter that keeps track of how much time has passed:
elapsed = elapsed + 0.03

You calculate a dX and dY offset for a simple linear movement:
dX = Cos(angle) * VELOCITY
dY = Sin(angle) * VELOCITY


You calculate the projected coordinates of the unit:
newX = UnitX+dX
newY = UnitY+dY


Then you determine the orthogonal offset value:
offsetX = Cos(angle-pi/2) *AMPLITUDE * Sin(elapsed/PERIOD*2*pi)
offsetY = Sin(angle-pi/2) * AMPLITUDE * Sin(elapsed/PERIOD*2*pi)


Then, in the final step, you just move your unit:
SetUnitPosition(unit, newX+offsetX, newY+offsetY)

VELOCITY is the linear travel speed in coordinate units / 0.03 seconds.
PERIOD is the time in seconds for the projectile to move from the left return point to the right and back again.
AMPLITUDE is the maximum orthogonal distance of the projectile from a straight linear travel.
ANGLE is the movement angle of your projectile. Remember that all trigonometric functions in Warcraft 3 use Radian input, not degrees.
 
Status
Not open for further replies.
Top