Jump to content

changing object rotation in unity

Spudwell06
Go to solution Solved by Spudwell06,
I have been making a basic car game, and once the car is upside down, it flips over.
 
i tried using:
transform.Rotate(0,0,0);
 
however it did nothing
 
I would like it to set the x and z axis to 0 and leave the y alone (as this is it's direction)
how would i do it?
 
SOLUTION:
transform.rotation = Quaternion.lookDirection(transform.forward)

 

 

I have been making a basic car game, and once the car is upside down, it flips over.
 
i tried using:
transform.Rotate(0,0,0);
 
however it did nothing
 
I would like it to set the x and z axis to 0 and leave the y alone (as this is it's direction)
how would i do it?
 
SOLUTION:
transform.rotation = Quaternion.lookDirection(transform.forward)

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

vector3 myNewRot = new Vector3(0.0f, transform.rotation.eulerangles.y, 0.0f;

Quaternion myConvertedRotation = new Quaternion.EulerAngles(myNewRot);

transform.rotation = myCpnvertrdRotation;
                               
                               //or something like that

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×