I am letting the user draw out a path on a tile grid by dragging the mouse. For each ‘node’ of the path, I create a plane with a texture on, which is a corner join texture if the path is changing direction there.
The corner sections need to rotate to join up with the preceding and following nodes. Therefore, when I add a new node, I am going back to the previous one to change its texture and rotate it correctly.
Right now I’m using this to rotate the corner sections:
Vector3 turnDirection = (newPosition.position - lastPosition.position).normalized; lastNode.transform.rotation = Quaternion.LookRotation(turnDirection, Vector3.up);
But this only works for left turns in the path. Right turns are not rotated properly. How can I get it to work for both directions?
An example of the problem (ignore my rubbish test textures ):