Search Unity

itween moveUpdate c# Doing nothing

Discussion in 'Scripting' started by Elbanes, Jan 18, 2014.

  1. Elbanes

    Elbanes

    Joined:
    Oct 26, 2013
    Posts:
    1
    Hello every body,

    I have a problem with this script. Normaly it must move the gameObject when you left click and update destination when you hold the left click.

    But itween.moveUpdate don't seems working at all.

    if you attach this script on simple object, you can easy test. (set main camera.z -9 and rotation.zero fo ZYX), I hope some one can help me.

    Regards

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class The_Entity_Moves : MonoBehaviour {
    6.     public float speed = 1;
    7.     private bool InMove = false;
    8.     private Vector3 Destination() {
    9.         return Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z));
    10.     }
    11.     void MoveEnd() {
    12.         InMove = false;
    13.     }
    14.     void Update() {
    15.         Vector3 Destination_ = Destination();
    16.         if(Input.GetMouseButton(0)) {
    17.             if(!InMove) {
    18.                 InMove = true;
    19.                 Hashtable ht = new Hashtable();
    20.                 ht.Add("speed", speed);
    21.                 ht.Add("position", Destination_);
    22.                 ht.Add("oncomplete", "MoveEnd");
    23.                 ht.Add("easetype", "linear");
    24.                 iTween.MoveTo(gameObject, ht);
    25.             } else {
    26.                 Debug.Log(Destination_);
    27.                 Hashtable ht = new Hashtable();
    28.                 ht.Add("position", Destination_);
    29.                 iTween.MoveUpdate(gameObject, ht);
    30.             }
    31.         }
    32.     }
    33. }
    34.