- Home /
Issues with transitions
I am working with a program that handles with the six degrees of freedom (left-right, up-down, front-back, yaw, pitch, roll). I am using iTween which is an AMAZING tool that is currently handling the object's movement. But, I AM having a bit of an issue. This diagram should help:
As you can see the object travels diagonally and I want it to where if its in the second state I want the position updated to the position I want it. But I don't know what I am doing wrong.
In my class I have it set up like so:
case ObjectAnimations.animation1:
MoveAcrossXPlane();
break;
case ObjectAnimations.animation2:
MoveAcrossYPlane();
break;
case ObjectAnimations.animation3:
MoveAcrossZPlane();
break;
case ObjectAnimations.animation4:
RotateObject_Pitch();
break;
case ObjectAnimations.animation5:
RotateObject_Yaw();
break;
case ObjectAnimations.animation6:
RotateObject_Roll();
break;
public void MoveAcrossXPlane()
{
iTween.MoveTo(_cubeObject_demo, iTween.Hash("name", "Xplane", "position", new Vector3(1, 1, 0), "speed", speed, "easetype", iTween.EaseType.linear, "looptype", iTween.LoopType.pingPong, "oncomplete", "PauseTween", "oncompletetarget", gameObject));
}
public void MoveAcrossYPlane()
{
_cubeObject_demo.transform.position = new Vector3(0, 1, 0);
iTween.MoveTo(_cubeObject_demo, iTween.Hash("name", "Yplane", "position", new Vector3(0, 1.7f, 0), "speed", speed, "easetype", iTween.EaseType.linear, "looptype", iTween.LoopType.pingPong, "oncomplete", "PauseTween", "oncompletetarget", gameObject));
}
//...rest of the methods go down here
The user presses a button and that is how I am controlling each state and in the class that has the GUI button I inserted the logic to stop each animation as well as placing the object where I want it:
switch (taskCounter)
{
case 0:
iTween.StopByName(obj_animateBlock._cubeObject_demo, "Xplane");
iTween.MoveTo(obj_animateBlock._cubeObject_demo, iTween.Hash("position", new Vector3(-1, 1, 0)));
break;
case 1:
iTween.StopByName(obj_animateBlock._cubeObject_demo, "Yplane");
iTween.MoveTo(obj_animateBlock._cubeObject_demo, iTween.Hash("position", new Vector3(0, 1, 0)));
break;
case 2:
iTween.StopByName(obj_animateBlock._cubeObject_demo, "Zplane");
iTween.MoveTo(obj_animateBlock._cubeObject_demo, iTween.Hash("position", new Vector3(0, 1, 0)));
break;
case 3:
iTween.StopByName(obj_animateBlock._cubeObject_demo, "Pitch");
iTween.MoveTo(obj_animateBlock._cubeObject_demo, iTween.Hash("position", new Vector3(0, 1.2f, 0)));
iTween.RotateTo(obj_animateBlock._cubeObject_demo, iTween.Hash("rotation", new Vector3(0, 0, 0)));
break;
case 4:
iTween.StopByName(obj_animateBlock._cubeObject_demo, "Yaw");
iTween.MoveTo(obj_animateBlock._cubeObject_demo, iTween.Hash("position", new Vector3(0, 1.2f, 0)));
iTween.RotateTo(obj_animateBlock._cubeObject_demo, iTween.Hash("rotation", new Vector3(0, 0, 0)));
break;
case 5:
iTween.StopByName(obj_animateBlock._cubeObject_demo, "Roll");
iTween.MoveTo(obj_animateBlock._cubeObject_demo, iTween.Hash("position", new Vector3(0, 1.2f, 0)));
iTween.RotateTo(obj_animateBlock._cubeObject_demo, iTween.Hash("rotation", new Vector3(0, 0, 0)));
break;
}
If anyone has any idea on how to fix this, I will be greatly appreciative. Thank you and God Bless.
Answer by gamenovice · Jan 08, 2014 at 04:45 PM
I'm not an expert in iTween, but you may want to check your MoveAcrossXPlane Method.
public void MoveAcrossXPlane()
{
iTween.MoveTo(_cubeObject_demo, iTween.Hash("name", "Xplane", "position", new Vector3(1, 1, 0), "speed", speed, "easetype", iTween.EaseType.linear, "looptype", iTween.LoopType.pingPong, "oncomplete", "PauseTween", "oncompletetarget", gameObject));
}
the part where you are declaring the Vector3 for the position has a 1 in both the x and y parameter spaces, that might be causing the diagonal issue you are seeing.
@gamenovice The reason for the 1 being in both x and Y is because the object is found in an elevated space (on top of a block) I know in the diagram I place a 0 where the Y is just for display. It was my bad and I am sorry for the mix up.
Your answer
![](https://koobas.hobune.stream/wayback/20220613125846im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Rotating an object using itween 1 Answer
using itween to move objects in the 6 degrees of freedom 1 Answer
Waiting between pingpong loops 2 Answers
Using iTween for custom variables 3 Answers