Search Unity

Help!! Rotate Script

Discussion in 'Scripting' started by ZeroZed, Jun 4, 2011.

  1. ZeroZed

    ZeroZed

    Joined:
    Jun 1, 2011
    Posts:
    4
    Am trying to make a Script that can Rotate on X,Y,Z. So i can change the var, So that i have different game objects that use the same Rotate script. But i want to change some game objects to rotate other ways then some. also change the speed of what there going. Please help.
    PHP:
    var speedForChangeint;

    function 
    Update () 
    {
        
    transform.Rotate(0speedForChange*Time.deltaTime,0);
    }
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Code (csharp):
    1. var rotateAxis : Vector3;
    2.  
    3. function Update ()  
    4. {
    5.     transform.Rotate(rotateAxis * Time.deltaTime);
    6. }
    So if e.g. you put 0, 45, 0 in rotateAxis, it will rotate 45 degrees per second around the Y axis.

    --Eric
     
  3. jtman562

    jtman562

    Joined:
    Dec 11, 2010
    Posts:
    368
    What exactly isn't that script doing? Can't help if I don't know what the problem is.
     
  4. ZeroZed

    ZeroZed

    Joined:
    Jun 1, 2011
    Posts:
    4
    thats what i need thanks so much Eric.