Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Let us know your feedback about the Global Illumination changes in the 2023.2 beta.
    Dismiss Notice
  3. Dismiss Notice

Method not working correctly in Unity 5

Discussion in 'Unity 5 Pre-order Beta' started by root8888, Nov 4, 2014.

  1. root8888

    root8888

    Joined:
    Jul 25, 2013
    Posts:
    26
    My method works perfectly in Unity 4, but does not act as expected in Unity 5. I don't know if I am doing something wrong or if it is something with iTween.

    With Unity 4, the method takes the current object, records its location, moves it to a random position off the screen, and then moves it to the original location with iTween. In Unity 5, everything works, except that the object doesn't move back to the original position. Here is the really strange part, the y and z position are always correct. The problem is only ever with the final x position. It actually feels like iTween is doing a MoveBy() instead of a MoveTo(), but only for the x position.

    Does anyone have any idea what might be going on?

    void FlyPegsIn() {
    // put the pegs in a random spot and fly them into their level position
    Vector3 startLocation = gameObject.transform.localPosition;

    float rangeX = Random.Range(-15.0f, 15.0f);
    if (rangeX > 0) { rangeX += 30.0f; }
    else { rangeX -= 30.0f; }

    float rangeY = Random.Range(20.0f, -10.0f);
    if (rangeY > 0) { rangeY += 20.0f; }
    else { rangeY -= 10.0f; }

    float rangeZ = Random.Range(50.0f, 0.0f)+40.0f;

    gameObject.transform.position = new Vector3(rangeX, rangeY, rangeZ);

    iTween.MoveTo(gameObject, iTween.Hash("x", startLocation.x,
    "y", startLocation.y,
    "z", startLocation.z,
    "time", Random.Range(0.5f, 3.0f),
    "easetype", "easeInOutQuad"));
    }​


    Thanks
     
  2. root8888

    root8888

    Joined:
    Jul 25, 2013
    Posts:
    26
    Anyone having success with iTween and beta 5 at all? If I am the only one having problems, it would be useful to know so.

    Thanks.
     
  3. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,117
    A little bit off topic, but I really wonder why people still use iTween. The last time I checked, it was many times the slowest of all the tween engines available.
    I'd recommend you use DOTween (http://dotween.demigiant.com/)
    There is a chart at the bottom of that page with comparison of various tween engines. You can pick something else, if for some reason you won't like DOTween, but I'd stay away from iTween.
     
    carking1996 and root8888 like this.
  4. root8888

    root8888

    Joined:
    Jul 25, 2013
    Posts:
    26
    This is new to me. Thanks.

    I grabbed a copy of DOTween. I had it installed and running in minutes working perfectly. I am also a big JQuery fan and love it's funtion chaining, so that feature is especially appealing in DOTween. I'm not looking forward to changing all my code over, but it's probably for the best. Thanks again.
     
    Devil_Inside likes this.