PDA

Click to See Complete Forum and Search --> : Projectile Wind


K-MAN
Feb 9th, 2002, 02:17 PM
Hi,
I am working on a game and i need a little help. In the game there are some projectiles(2d) being thrown. If someone could please help me add wind I would appriciate it. This is what i have so far in my loop. Everthing works so far, i just want a varible that willadd wind because i want to be able to change the strength and direction(left or right) at certain points. Thank you :)

do
.xcord = (Power(X) * Cos(Angle(X) * 3.14159 / 180) * .time)+ .startx


.ycord = .starty - (Power(X) * Sin(Angle(X) * 3.14159 / 180) * .time - 4.9 * .time ^ 2)

.time = .time + 0.1
loop

Zaei
Feb 9th, 2002, 04:09 PM
Instead of using Angles to specify the direction of the projectile, use vectors, as you get far more control. Then, wind is easy. You simple have another vector for the wind direction, and a single for wind power. Then, do something like this:

Pos.x = Pos.x + (Vel.x + (Wind.x * windSpeed) *.time)
Pos.y = Pos.y + (Vel.y + (Wind.y * windSpeed) *.time)
'if 3d...
Pos.x = Pos.z + (Vel.z + (Wind.z * windSpeed) *.time)


Z.