2017-04-24 83 views
0

我有一个脚本,当点击它时会使对象旋转。我想看看是否将iTween添加到它可以改善运动,但我应该在哪里添加它?Unity,C#和iTween

的ITween代码:

iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType", "pingPong", "delay", .4)); 

脚本:

using UnityEngine; 
using System.Collections; 

public class rotate : MonoBehaviour { 

    public float minX = -360.0f; 
    public float maxX = 360.0f; 

    public float minY = -3660.0f; 
    public float maxY = 360.0f; 

    public float sensX = 500.0f; 
    public float sensY = 500.0f; 

    float rotationY = 0.0f; 
    float rotationX = 0.0f; 

    void Update() { 

     if (Input.GetMouseButton (0)) { 
      rotationX += Input.GetAxis ("Mouse X") * sensX * Time.deltaTime; 
      rotationY += Input.GetAxis ("Mouse Y") * sensY * Time.deltaTime; 
      rotationY = Mathf.Clamp (rotationY, minY, maxY); 
      transform.localEulerAngles = new Vector3 (rotationY, -rotationX, 0); 
     } 
    } 
} 

回答

0

你的意思是你要替换现有的轮换代码使用与ITween功能也是这样吗?

void Update() { 

    if (Input.GetMouseButton (0)) { 
     iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType", "pingPong", "delay", .4)); 
    } 
} 
+0

非常感谢你..会检查出来:) –