Reputation: 129
Hello im not that new to unity but i want to achive this :
I have no idea how many people say ik but its too complex and some say with Quaternion but they dont explain how shoud i do it so if someone has a idea please share thank you . Im using A* pathfinding and using the example AI they have i tried using AIlerp that does what i want but it has alot of bugs :)
Upvotes: 1
Views: 166
Reputation: 4888
You need to get the surface normal and apply it to the object. First find the vector that goes from point A to point B, rotate it by 90 degrees and finally normalize it.
Here's some pseudo code:
Vector3 pointA = new Vector3(x,y,z);
Vector3 pointB = new Vector3(x,y,z);
Vector3 dir = pointB - pointA;
Vector3 normal = new Vector3(-dir.y, dir.x).normalized;
object.transform.up = normal;
Upvotes: 2