# Trying to make a Projectile Rotate and Move Forward..

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!

var X: int;
var Y:int;
var Z: int;

``````var rotationsPerMinute : float = 10.0;
function Update()
{
transform.Rotate(X,Y,Z*rotationsPerMinute*Time.deltaTime,0);
}
``````

attatch this to the object you want to spin,
have a second object an empty, atatch a script to make it move on instantiation, attatch you rotating object as a child object,
what your doing presently is rotating while moving forward which will produce a circle