如何旋转一个游戏对象每按一次键?顺利使用像lerp这样的东西?

时间:2016-03-28 10:59:37

标签: rotation slide flip flipper

我想旋转每个按键(左右)!

public class BoxFlipper : MonoBehaviour { 

   private Vector3 newRotation;

   void Update () {
             Button();
   }

   private void Button () {
             if (Input.GetKeyDown(KeyCode.Right))
                       FlipRight();
              if (Input.GetKeyDown(KeyCode.Left))
                       FlipLeft();
   }

   private void FlipRight () {
        newRotation = new vector3 (0,0,90);
        transform.rotation= Quaternion.Slerp(transform.rotation, newRotation.rotation, .05f);  
   }

   private void FlipLeft () {
        newRotation = new vector3 (0,0,-90);
        transform.rotation= Quaternion.Slerp(transform.rotation, newRotation.rotation, .05f);  
   }

}

0 个答案:

没有答案