Game Development Community

Projectile at certain angle

by Greg C · in Torque Game Builder · 04/28/2014 (9:31 pm) · 1 replies

How would I go about getting a projectile to move at a certain angle, such as based on the rotation of a sprite? So if the sprite rotation is 37 degrees, the projectile is shot out from the sprite at 37 degrees and so on (potentially with variable speeds). Thank you.

#1
04/29/2014 (7:01 am)
Get a unit vector pointing in the direction you want it to go and then use
%object.setLinearVelocity(%vecX * %speed, %vecY * %speed);
Where %object is your scene object, %vecX is the x component of your unit vector, %vecY is the y component of your unit vector, and %speed is the velocity that you want it to move at.