- Home /
Weird Output from AngleAxis
Quaternion.AngleAxis is giving me weird output/rotation when Im using it to set the rotation of my player object to look at my mouse in a 2d X/Y Plane.
Here's a snippet of where the problem is believed to be
mouseDir = Camera.main.ScreenToWorldPoint(Input.mousePosition) - child.transform.position;
shootAngle = Mathf.Atan2(mouseDir.y, mouseDir.x) * Mathf.Rad2Deg;
child.transform.rotation = Quaternion.AngleAxis (shootAngle, Vector3.forward);
child.transform.rotation.z (the z axis) of the object is returning 0, which is perfect, but shootAngle is returning 6, this is making rotations of instantiated offset.
Here's an image to represent my problem.
As you can see when my cursor is exactly horizontal to the player, the player's rotation is at 0, but the AngleAxis(shootAngle) returns me a 6 degrees as the rotation, shouldn't it be at 0 as well? When I instantiate objects using the player's rotation is shoots the object 6 degrees.
Your answer
Follow this Question
Related Questions
Rotate within range 1 Answer
Always rotating an object to a set angle? 0 Answers
How do I call a function containing a while loop, inside the update function? 2 Answers
Angle to Rotation 2 Answers
0-360 Y degree from Vector3.Angle 1 Answer