I have a script which makes an object rotate when you click on it. I would like to see if adding iTween to it would improve the motion, but where should I add it?
iTween code:
iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType", "pingPong", "delay", .4));
Script:
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);
}
}
}
Do you mean you wish to replace your existing rotation code to use the iTween function like this?