Scripting Animation iTween.RotateTo

Rotate To

 All Example With RotateTo that you can perform


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateTo : MonoBehaviour
{
    public float time;
    public GameObject objectToRotate;
    public iTween.EaseType easetype;
    public Vector3 angle;
    public float delay;
    public float x,y,z;
    public float speed;
    public void RotateExample1()
    {
        // just simple rotate to perticular angle
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle));
    }
    public void RotateExample2()
    {
        // just simple rotate to perticular angle over time
        iTween.RotateTo(objectToRotate,iTween.Hash("rotation",angle,"time",time));
    }
    public void RotateExample3()
    {
        // just simple rotate to perticular angle with easetype
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "time", time,"easetype", easetype));
    }
    public void RotateExample4()
    {
        // just simple rotate to only one axis angle
        iTween.RotateTo(objectToRotate, iTween.Hash("x", x, "time", time, "easetype", easetype));
        //iTween.RotateTo(objectToRotate, iTween.Hash("x", x, "y",y, "time", time, "easetype", easetype));
        //iTween.RotateTo(objectToRotate, iTween.Hash("x", x,"y",y,"z",z, "time", time, "easetype", easetype));
    }

    public void RotateExample5()
    {
        //use this if object is child of any game object for local rotation
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "time", time, 
            "easetype", easetype ,"islocal",true));
    }

     public void RotateExample6()
    {
        //if you want to use speed instead time
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "speed", speed, 
            "easetype", easetype ));
    }

    public iTween.LoopType looptype;
    public void RotateExample7()
    {
        //if you want to repeat that rotation
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "delay", delay, "time", time,
            "easetype", easetype,"looptype", looptype));
    }

    public void RotateExample8()
    {
        //if you want to perform any function when rotation start
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "delay", delay, "time", time,
            "easetype", easetype, "onstart", "PerformWhenStart", "onstarttarget", gameObject));
    }
    void PerformWhenStart()
    {
        Debug.Log("Rotation Started");
    }

    public void RotateExample9()
    {
        //if you want to perform any function when rotation is on going
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "delay", delay, "time", time,
            "easetype", easetype, "onupdate", "PerformEveryStep" , "onupdatetarget",gameObject));
    }
    void PerformEveryStep()
    {
        Debug.Log("Rotating");                    
    }

    public void RotateExample10()
    {
        //if you want to perform any function when rotation complete
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "delay", delay, "time", time,
            "easetype", easetype, "oncomplete", "OnRotationComplete", "onCompleteTarget", gameObject));
    }
    void OnRotationComplete()
    {
        Debug.Log("Rotating");
    }

    public void RotateExample12()
    {
        //if you to rotate when timescale is 0  use is when designing pause menu
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "delay", delay, "time", time,
            "easetype", easetype, "ignoretimescale",true));
    }
    public void RotateExample13()
    {
        //if you want to pass any argument when rotation complete
        iTween.RotateTo(objectToRotate, iTween.Hash("rotation", angle, "delay", delay, "time", time,
            "easetype", easetype, "oncomplete", "OnRotationCompleteParam", "onCompleteTarget", gameObject,
            "oncompleteparams", 5));
    }
    void OnRotationCompleteParam(float value)
    {
        Debug.Log("Rotating" + value);
    }

}


Comments