Game Development Community

How do I rotate an object as it's flying through the air?

by John Klimek · in Torque Game Builder · 03/06/2006 (5:05 pm) · 1 replies

Two questions actually...

1) If I have my t2dScene set with a constant force of "-15 50" (eg. wind blowing left at 15 and "gravity" set to 50) and I then launch a projectile (eg. setImpulseForcePolar), as the object is flying through the air it is not rotating. How can I fix that?

2) What is the "gravitic" parameter on setConstantForce and setImpulseForcePolar? In my game (Scorched Earth / Tanks clone) I'd like to have wind and gravity affecting all of my projectiles. Do I need to set "gravitic" to true? What does it do?

#1
03/06/2006 (5:36 pm)
1) Vector math again: You can get the linear velocity of the projectile. Just set the projectile's rotation to the angle of the velocity vector. You could do this in the onTimer callback.
Or you give the projectile the appropriate angular velocity at the beginning.

2) if "gravitic" is set to true then the force will be implied on objects regardless of their mass. So in your game, gravity should be gravitic (...) but I don't know about the wind.
Remember, computer game physics don't have to imitate the real world. It just has to work for the game.

-Michael