I’m trying to make a projectile move forward and rotate as it does so.
Here is the code I currently have for the projectile’s movement:
function Update () {
if(travelRight){
transform.Translate(Vector3(-speed * Time.deltaTime * 2, 0, 0));
transform.Rotate(Vector3(0, 0, 20));
Destroy(gameObject, 3);
}
if(!travelRight){
transform.Translate(Vector3(speed * Time.deltaTime * 2, 0, 0));
Destroy(gameObject, 3);
}
}
In the “if(travelRight){” statement, the projectile just instantiates and rotates in place.
Whereas in the “if(!travelRight){” statement, the object obviously just moves to the left.
I want the projectile to travel right or left, but rotate as it does so, and if I add any rotate function (so far) the projectile rotates and doesn’t move forward. And if it does make any movement forward, it’s not a local rotation. It ends up being a circular, global-like rotation. Does anybody know how to fix this? I’ve tried so many things and keep failing any help would be greatly appreciated!! Thanks
it’s a rigidbody, btw.
EDIT:
I have since just made a sprite to fake the look of rotation, but knowing this information would still be useful. Thanks!