- Joined
- Sep 21, 2007
- Messages
- 517
Alright guys, basically i was scouring for a function that works correctly for Z height movement for the bullet, as usual, i failed, then i found Diablo-Dks suggestion which had a bit of math it was something like sin(ZAxis)*speed or something like that, anyhow, i failed at getting the ZAxis and even looked at Cartesian 3D Plane, and failed at at also... then i went to the very basic laws of physics, T = D/S, so what i did was get the time between the two distances, T = D/S, then i had a variable for the Z difference between the target location and the beginning location, which gets the correct height transition i needed, now after that i here is what i did
i checked if z2 is greater than z1 or not, then
if z1 is greater than z2 then set dz (the height difference) = dz + (dz/T)
else set dz = dz + (dz*T)
NOw the final step
depending on the interval of the timer, which moves the unit every INTERVAL seconds... set dz = dz*INTERVAL
now to make it go in a linear line, just do this to height, every interval, set unit height = unit height + dz, make sure the bullet or particle or w/e has an initial height of w/e so it can launch correctly (depends on how tall your unit is where you want to shoot, for example, for rifle man an initial height of 50 or 75 would be good since it looks like he shoots from his gun )
Thats all folks! hope i helped anyone strugglign with these issues... but please know this doesnt work as effectively as other mathematical algorythms, i just came up with this.
i checked if z2 is greater than z1 or not, then
if z1 is greater than z2 then set dz (the height difference) = dz + (dz/T)
else set dz = dz + (dz*T)
NOw the final step
depending on the interval of the timer, which moves the unit every INTERVAL seconds... set dz = dz*INTERVAL
now to make it go in a linear line, just do this to height, every interval, set unit height = unit height + dz, make sure the bullet or particle or w/e has an initial height of w/e so it can launch correctly (depends on how tall your unit is where you want to shoot, for example, for rifle man an initial height of 50 or 75 would be good since it looks like he shoots from his gun )
Thats all folks! hope i helped anyone strugglign with these issues... but please know this doesnt work as effectively as other mathematical algorythms, i just came up with this.