- Home /
iTween RotateTo
I need help. Here's my code.
ublic class Rotation02 : MonoBehaviour {public Transform target; public Transform target2;
// Update is called once per frame void Update () {
if (Input.GetKeyUp(KeyCode.R))
iTween.RotateTo(gameObject,iTween.Hash("rotation",target.position,iTween.EaseType.easeInOutSine,"time",1.3f));
if (Input.GetKeyDown(KeyCode.R))
iTween.RotateTo(gameObject,iTween.Hash("rotation",target2.position,"easetype",iTween.EaseType.easeInOutSine,"time",.9f));
}
}
I can play the scene but when I press R I get an error that says:
NullReferenceException: Object reference not set to an instance of an object iTween.CleanArgs (System.Collections.Hashtable args) (at Assets/Standard Assets/Scripts/iTween/Plugins/iTween.cs:6745) iTween.RotateTo (UnityEngine.GameObject target, System.Collections.Hashtable args) (at Assets/Standard Assets/Scripts/iTween/Plugins/iTween.cs:2287) Rotation02.Update () (at Assets/Standard Assets/Scripts/General Scripts/Rotation02.cs:11)
I get another error that says:
Tween Error: Hash requires an even number of arguments! UnityEngine.Debug:LogError(Object) iTween:Hash(Object[]) (at Assets/Standard Assets/Scripts/iTween/Plugins/iTween.cs:6530) Rotation02:Update() (at Assets/Standard Assets/Scripts/General Scripts/Rotation02.cs:11)
The game object that has the script just rotates to the side when I press R.
Any input is appreciated.
Answer by dannyskim · Sep 29, 2012 at 08:42 PM
iTween.RotateTo(gameObject,iTween.Hash("rotation",target.position,iTween.EaseType.easeInOutSine,"time",1.3f));
You need an "easetype" before iTween.EaseType.easeInOutSine.
Why Should I use 'target.position' in case of rotation?
Your answer
Follow this Question
Related Questions
iTween RotateTo in C# 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Initialising List array for use in a custom Editor 1 Answer
iTween input with spring 1 Answer