transform.Rotate changed direction problem

Hi,

I’m moving a gameObject with transform.Rotate to two points and two directions sequentially… The first move run fine , but the second dont go to the right direction . Seems like the gameObject mix the first and the seconds direction.

How I do this moviment or how I reset rotation angle without change position/look location?

Well… I solve my problem.

I create a GameObject to be a parent of my rotate object and rotate this. After I change to another temp parent and reset gameobject transform.rotation… Rotation dont spread if you only change the parent. :smiley:

if you need use N rotation try this, use a parent to move, move you child to tempParent and reset your main parent rotation:

Code ahead:

            if( fracComplete >= 1 )
			{
				this.state 	= GameStates.stopped;
				
				var angle : Vector3  = this.transform.localEulerAngles;
				
				angle.x = Mathf.Round( angle.x / 90 ) * 90;
				angle.y = Mathf.Round (angle.y / 90 ) * 90;
				angle.z = Mathf.Round( angle.z / 90 ) * 90;
				
				this.transform.localEulerAngles = angle;
				
				face1.transform.parent = tmpCube.transform;
				face2.transform.parent = tmpCube.transform;
				face3.transform.parent = tmpCube.transform;
				face4.transform.parent = tmpCube.transform;
				face5.transform.parent = tmpCube.transform;
				face6.transform.parent = tmpCube.transform;
				
				angle = this.transform.localEulerAngles;
				
				angle.x = 0;
				angle.y = 0;
				angle.z = 0;
				
				this.transform.localEulerAngles = angle;
							
				face1.transform.parent = this.transform;
				face2.transform.parent = this.transform;
				face3.transform.parent = this.transform;
				face4.transform.parent = this.transform;
				face5.transform.parent = this.transform;
				face6.transform.parent = this.transform;			
			}