LookAt() rotating the wrong way
Hey everyone,
I've got this problem:
I'm trying to add in a List, all of the positions and rotations that the agent needs to do, to go from a point to another.
The problem is that when I use the lookAt() the agent, sometimes, rotates to the wrong way (normally when he's pointing to (-1,0,0) and I want him to go left or when he's pointing to (1,0,0) and I want him to go right).
Code:
     List<MoveInfo> moves = new List<MoveInfo>();
     Vector3 initPos = selectedTransform.position;
     Quaternion initRot = selectedTransform.rotation;
     foreach (Vector2 position in movePositions)
     {
         //Calculate Rotation
         selectedTransform.LookAt(new Vector3(position.x, initPos.y, position.y));
         //Calculate Position
         selectedTransform.position = new Vector3(position.x, initPos.y, position.y);
         //Add new Move
         moves.Add(new MoveInfo(selectedTransform.position, selectedTransform.rotation));
     }
     selectedTransform.position = new Vector3(initPos.x, initPos.y, initPos.z);
     selectedTransform.rotation = new Quaternion(initRot.x, initRot.y, initRot.z, initRot.w); 
     return moves;
 
Thanks, Pedro Gomes
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                