Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Mupp on January 17, 2021, 10:47:59 AM

Title: Transform local quaternion to global
Post by: Mupp on January 17, 2021, 10:47:59 AM
How can I transform a local quaternion variable to global?
Title: Re: Transform local quaternion to global
Post by: Mupp on January 20, 2021, 07:35:47 PM
bump
Title: Re: Transform local quaternion to global
Post by: Mupp on January 24, 2021, 02:54:14 PM
bump again

Didn't think this was such an odd question.
Title: Re: Transform local quaternion to global
Post by: nuFF3 on January 24, 2021, 05:33:30 PM
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.
Title: Re: Transform local quaternion to global
Post by: Mupp on January 24, 2021, 08:05:38 PM
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.
Title: Re: Transform local quaternion to global
Post by: LordHorusNL on January 25, 2021, 01:22:41 AM
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;
Title: Re: Transform local quaternion to global
Post by: Mupp on January 25, 2021, 02:42:13 PM
Oh, I thought euler angles was something completely different, but it actually just converts it to a vector. Thanks.