I’m trying to get the angle between two vectors from the perspective of a plane. Sounds like exactly what SignedAngle(Vector3 from, Vector3 to, Vector3 axis) is supposed to do. However i’m not getting the result that i want and now i want to know if i don’t use the function correctly, if the function is not doing what i think it is, or if it is just plainly a bug.
In short: if i move one vector parallel to the “axis” the returned angle also changes, even though viewed from “axis” the moved vector only differs in length to that perspective, not in angle…
Long story: I have 3 Nodes, A parent, the current Node, and a child. I’m trying to get the roll angle between the parent orientation (so the parents up vector) and the direction of the child.
So what i do is “look at the scene” from the parent’s forward vector and determine the angle between the parents up vector and the direction vector of the child.
Vector3 parentForward = parent.transform.TransformDirection(Vector3.forward); Vector3 parentUp = parent.transform.TransformDirection(Vector3.up); Vector3 childDirection = (child.transform.position - current.transform.position).normalized; float roll = Vector3.SignedAngle(parentUp, childDirection, parentForward);
If i now rotate the child around the parent on the global x axis (parents z axis) everything works as intended, as seen in the left image of the following illustration (viewed from the front = global -x axis).
If i however rotate the child in the global z axis (parents -x axis) the angle also gradually decreases, as if i had just rotated it for the same amount on the global x axis (right image, viewed from behind = global z axis)
But as the given rotation Axis is the global x axis, rotating around the z axis should not have an effect on the result, at least as far as i understand it. (at least not until i overshoot the 90° where the angle between parent and child turns from 180° to 0° instantly)
is this intended behaviour? if so, what is the parameter “axis” for?