Rotate to a set degree then stop Unity

Posted by N0xus on Game Development See other posts from Game Development or by N0xus
Published on 2012-10-03T15:54:47Z Indexed on 2012/10/03 21:56 UTC
Read the original article Hit count: 216

Filed under:
|
|

I'm trying to make an object rotate up on the Y axis 90 degrees, then stop. I've got the rotating up bit working fine, it's getting it to stop once it hits 90.

Some of the things I've tried include the following:

float i = rotateSpeed * Time.deltaTime; 
while ( x != 90 )
        {
        transform.Rotate( i, 0, 0);
        }   

        int x = 0; 
x++;

        if( x == 90 )
        {
            transform.Rotate( 0, 0, 0 );
        }

For some reason I can't get this simple thing to work. What am I missing / not doing?

© Game Development or respective owner

Related posts about c#

Related posts about unity