I have a road tool that when I click and release the mouse button it creates the mesh and rotates it so the road starts and ends where the mouse events occurred. However, when I build a road on a hill one of the axis when doing this rotation always gets messed up.
I want the road to always face up, which as you can see on the pic it is facing to the side a bit.
I have tried everything I could gather for 1 week and nothing seems to work.
Code that im using in the picture to rotate:
road.transform.rotation = Quaternion.FromToRotation(Vector3.right, end - origin);
I have also tried the Rotate() method:
float angle = Vector3.Angle(Vector3.right, end - origin); road.transform.Rotate(Vector3.up, angle, Space.World);
I tried to get the angle between the current up and Vector3.up but I was getting garbage don’t know why.
And many more but nothing works, I’m getting frustrated with this.
Can someone assist me please?