Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Mupp on January 17, 2021, 10:47:59 AM
-
How can I transform a local quaternion variable to global?
-
bump
-
bump again
Didn't think this was such an odd question.
-
You know how to use google don't you?
If not -> http://letmegooglethat.com/?q=unity+quaternion+local+to+world (http://letmegooglethat.com/?q=unity+quaternion+local+to+world)
Literally one of the first results:
https://forum.unity.com/threads/how-to-i-convert-a-local-rotation-to-a-global-rotation-for-the-object.470309/ (https://forum.unity.com/threads/how-to-i-convert-a-local-rotation-to-a-global-rotation-for-the-object.470309/)
https://answers.unity.com/questions/301085/transform-global-quaternion-from-local-quaternion.html (https://answers.unity.com/questions/301085/transform-global-quaternion-from-local-quaternion.html)
You apply these principles to playmaker and 'hey presto', you've got what you wanted.
No need to bump, just learn to research.
-
Yes, I've read those too, since I actually searched before posting.
The problem is that I can't figure out how to do the maths on a "quaterninon variable". I can't find an action that converts it to a vector3 so I can use the math actions in Playmaker. If this is possible it's not obvious to me.
-
You can convert a Quaternion to a Vector3 by using the "Get Quaternion Euler Angles" action that's included with PlayMaker.
I believe you should also be able to get the world rotation by using another object's rotation as an offset. Most commonly the parent object's rotation.
"Get Rotation" to get the world rotation of the parent as a quaternion.
"Get Quaternion Multiplied by Quaternion" action to multiply your parent's rotation by your local rotation.
Quaternion worldRotation = transform.parent.rotation * localRotation;
-
Oh, I thought euler angles was something completely different, but it actually just converts it to a vector. Thanks.