Search Unity

How could I rotate a player based on his spine's rotation?

Discussion in 'Scripting' started by Marjo_Borestag, Jul 24, 2014.

  1. Marjo_Borestag

    Marjo_Borestag

    Joined:
    Aug 14, 2013
    Posts:
    14
    Basically I am trying to make a script where player starts rotating on Y axis only when the spine's bone reaches a certain rotation.

    Here's the code:

    Code (CSharp):
    1.         if (playerSpine.localEulerAngles.x <= rotLeftMax && playerSpine.localEulerAngles.x >= rotLeftMin || playerSpine.localEulerAngles.x == rotLeftMax)
    2.                         transform.Rotate (0, -rotSpeed, 0);
    3.         if (playerSpine.localEulerAngles.x <= rotRightMin && playerSpine.localEulerAngles.x >= rotRightMax || playerSpine.localEulerAngles.x == rotRightMax)
    4.                         transform.Rotate (0, rotSpeed, 0);
    The problem is that the rotating stops when it reaches the rotRightMax or rotLeftMax instead of still going.
     
    Last edited: Jul 24, 2014