- Home /
Question is off-topic or not relevant
Method not working correctly in Unity 5
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
Follow this Question
Related Questions
iTween syntax error? orienttopath with moveto 1 Answer
Go back to first node (itween + moveto) 2 Answers
iTween movetopath 1 Answer
Stacking iTween.MoveTo calls 1 Answer
itween moveto not working 1 Answer