playMaker

Author Topic: How to actually USE quaternions in a game  (Read 2215 times)

ManicMinerUK

  • Junior Playmaker
  • **
  • Posts: 51
How to actually USE quaternions in a game
« on: October 20, 2016, 10:42:35 AM »
Hi there,

Just wondered if any kind soul out there could give me an actual example of how to use the Quaternion actions provided in Playmaker to do something practical?

I have an object I need to rotate from orientation(A) to orientation(B) over a period of time. If I try and do this with euler angles, there are obvious gimbal-lock type problems.
But I cannot understand what the quaternion actions even do, and there don't seem to be any clear equivalencies between the quaternion actions and the various euler ones (set/get rotation, rotate etc), so I'm just totally confused as to how I'm supposed to use these actions.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to actually USE quaternions in a game
« Reply #1 on: October 24, 2016, 10:15:04 AM »
Hi,

It's indeed a very important topic, and mastering quaternions action will make your life easier!

 the first thing to do is to read documentation on this in Unity, as the quaternion actions simply exposes these methods that you script in c#.

https://docs.unity3d.com/ScriptReference/Quaternion.html


Then you can get the Ecosystem and search for samples on quaternions:




Get them samples ( make a dedicated projects for PlayMaker samples so that you don't overload your projects with them).
 
a simple one is the tipping cube, the logic to get the right axis and all is not important, focus on the "animate" state of the TippingCube" Fsm, it uses QuaternionRotateTowards and shows you how to animate a transform that way with total flexibility, something you can achieve with tweening engines too, but here I show you how to do that manually.

If you have then questions on a particular use for a specific result or specific Action, let me know, it will be easier to answer precisly.

Bye,

 Jean