- Home /
itween moveto not working
Hi, i'm facing a problem which unable to trigger my own method after the iTween.MoveTo(..) finished run.
My Code
using UnityEngine;
using System.Collections;
public class InGameScript : MonoBehaviour {
public Transform cardPrefab;
void Awake(){
}
void Update () {
}
void Start(){
GameObject selectedObj = (Instantiate(cardPrefab, _position, Quaternion.identity) as Transform).gameObject;
Vector3[] pos = new Vector3[2];
card3[0] = new Vector3(-1.04f, -1.41f, 0);//to
card3[1] = new Vector3(-1.04f, -1.41f, 0);//to
Hashtable hh = new Hashtable();
hh.Add("path",pos);
hh.Add("speed",10);
hh.Add("delay",1);
hh.Add("easetype",iTween.EaseType.easeInQuint);
hh.Add("oncomplete","OnMoveComplete");
hh.Add("oncompletetarget",selectedObj);
iTween.MoveTo(selectedObj, hh);
}
void OnMoveComplete()
{
Debug.Log("Testing");
}
}
itween's parameters reference : http://itween.pixelplacement.com/documentation.php
Please advise.
Thanks, jenz
The oncompletetarget param should be the receiver gameobject, which is this.gameObject in this case.
Answer by DannyB · Jul 16, 2013 at 11:43 AM
Change this:
hh.Add("oncompletetarget",selectedObj);
to this:
hh.Add("oncompletetarget",gameObject);
All on___target
parameters in iTween should be the game object that defines their equivalent method.
As an aside, you may find it less clunky to use iTween's Hash "builder". To me this feels a little more natural, but its a matter of taste:
iTween.MoveTo(selectedObj, iTween.Hash(
"path" , pos,
"speed" , 10,
"delay" , 1,
"easetype" , iTween.EaseType.easeInQuint,
"oncomplete" , "OnMoveComplete",
"oncompletetarget", gameObject
));
Your answer
Follow this Question
Related Questions
Stacking iTween.MoveTo calls 1 Answer
iTweens MoveTo and "path" property 7 Answers
iTween MoveTo with LookAt 1 Answer
iTween MoveTo + Rotation? 2 Answers
iTween moveby constrained by rigidbody constraints in Unity 5 2 Answers