itween path reverse direction without the object rotating around

I have a conveyor belt and use IteenPath to move objects on it to follow the conveyor path as it makes turns. The conveyor can be switched forward and reverse.

When moving forward it works fine, but when moving the conveyor in reverse directionthe object first rotates 180 degrees.
I do not want it to rotate but I still want it to orient on path.
Is this possible?

var moveObject 				:GameObject;
var targetPath 				:GameObject;
var pathNameForward			:String = "none";
var pathNameReverse			:String = "none";
var conveyorSpeed 			:int = 4;



//--------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------
function GoForward() :IEnumerator
{
	if(pathNameForward == "none")
	{
		ErrorBlink(true);
	}
	else
	{
		OtherEffects();
		
		// Wait for doors to open
		yield WaitForSeconds(2);
		
		BeltAnimation();
		
										
		rItweenPathScript.SetStartPoint(moveObject.transform.position);
		iTween.MoveTo(moveObject, iTween.Hash("path", rItweenPathScript.GetPath(pathNameForward), "orienttopath", true , "speed", conveyorSpeed, "easetype", "linear", "oncomplete", "OnEndPath", "oncompletetarget", this.gameObject));
	
		// Start pushing objects on conveyor.
		rPushTrack.Enable(false);
	}
}



//--------------------------------------------------------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------------------------------------------------------
function GoReverse() :IEnumerator
{	
	if(pathNameReverse == "none")
	{
		ErrorBlink(true);
	}
	else
	{
		OtherEffects();
		
		// Wait for doors to open
		yield WaitForSeconds(2);
		
		BeltAnimation();
		rItweenPathScript.SetStartPoint(moveObject.transform.position);
			
		iTween.MoveTo(moveObject, iTween.Hash("path",rItweenPathScript.GetPathReversed(pathNameReverse), "orienttopath", true , "speed", conveyorSpeed, "easetype", "linear", "oncomplete", "OnEndPath", "oncompletetarget", this.gameObject));
				
		// Start pushing objects on conveyor.
		rPushTrack.Enable(true);
	}
}

I believe you want to use the axis parameter. iTween for Unity by Bob Berkebile (pixelplacement) “axis-string-restricts rotation to the supplied axis only”

So, I believe your code should look something like this:

iTween.MoveTo(moveObject, iTween.Hash("path",rItweenPathScript.GetPathReversed(pathNameReverse), "orienttopath", true, "axis", "yz", "speed", conveyorSpeed, "easetype", "linear", "oncomplete", "OnEndPath", "oncompletetarget", this.gameObject));

If I’m right this should restrict rotation to only the y and z axes.

I solved the issue.

I created a gameobject named ‘platform’ that follows the path and has a script that parents/unparents the item that I have on the conveyor.

  • When moving forward I first parent my actual object named ‘station’ and send the itween commande to move, when it reached the end of the path it calls a function that unparents again.
  • And now the magic :wink: When moving reverse, I first rotate the ‘platform’ local y axis 180 degrees (localrotation.y += 180;) so the forward angle already faces the reverse path direction eliminationg the 180 rotation on trigger. Next I parent the actual object ‘station’ to the ‘platform’ and call the itween reverse path move. At completion of the path I call a function to unparent the ‘station’ again and return the ‘platform’ to its normal forward direction with localrotation.y -= 180;
  • At this point I can trigger to move forward or backwards again whatever the player decides.

This way my ‘station’ object will always face the same direction on the conveyor moving forward/backwards while turning when the conveyor makes a turn.