I’m making a top down shooter. My character shoots triangles.
I calculate the direction of the triangle by subtracting the player position from the mouse position. Then, I use the resulting vector to get a Quaternion to use when instantiating the bullet. However, the angles are all wrong.
Vector3 dir = MousePosition() - playerPos;
Quaternion q = Quaternion.FromToRotation(dir , Vector3.up);
GameObject instancedObj = GameObject.Instantiate(spell, MousePosition(), q, null);

These are the angles that I’m getting. I’ve tried switching dir to - dir and changing the direction of the second argument in the Quaternion constructor but the angles are always wrong.
What am I doing wrong with the angles?
P.S.: the triangle is pointing upwards when I use Quaternion.identity.
It still seems that order of some things is messed up.
Probably should be:
Quaternion.FromToRotation(Vector3.up, dir)
instead of
Quaternion.FromToRotation(dir, Vector3.up)
Other quick fix for this would be to use inverse of the quaternion that you’re using:
Quaternion.Inverse(q)
instead of just q.