playMaker

Author Topic: Quaternion.RotateTowards  (Read 4396 times)

zombie

  • Playmaker Newbie
  • *
  • Posts: 9
Quaternion.RotateTowards
« on: March 06, 2017, 10:43:03 PM »
I'm rotating an object. In a script, I would use the following.

Code: [Select]
transform.localRotation = Quaternion.RotateTowards(transform.localRotation, objectEndRotation, Time.deltaTime * rotationSpeed);
In Playmaker, I got the same job done with:



Is that the correct way to accomplish the same thing?

Also, what is the order of execution? Does the action at the top execute first?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quaternion.RotateTowards
« Reply #1 on: March 07, 2017, 12:43:03 AM »
Hi,

 almost :)

- you forgot to multiply your MaxdegreesDelta with Time.Deltatime, this is important.

- also, depending on where this line of code is called, you'll have to also reflect this, for now you are doing this operation "on Update", but if it turns out you need to use on "fixed update" or on "Late Update", then you'll have to use "getRotationAdvanced", SetRotationAdvanced" to access when to execute this action ( rotateTowards already have this).

-- yes, actions are executed top down.

Bye,

 Jean

 Bye,

 Jean

zombie

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Quaternion.RotateTowards
« Reply #2 on: March 07, 2017, 12:53:19 AM »
I have no idea how to multiply it my Time.Deltatime.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quaternion.RotateTowards
« Reply #3 on: March 07, 2017, 12:58:16 AM »
Hi,

 use the action GetTimeInfo, store the deltatime in an Fsmfloat, then multiply it by 10, the result is what you need to use inside the RotateTowards action.

 Bye,

 Jean

zombie

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Quaternion.RotateTowards
« Reply #4 on: March 07, 2017, 02:15:02 AM »
Would this do the job?

(with Every Frame checked on the bottom)


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quaternion.RotateTowards
« Reply #5 on: March 07, 2017, 08:08:32 AM »
hi,

 nop, you also need to check "everyframe" for the multiplication of 10 * Time.Deltatime.

 you need to fully understand what Deltatime is, it's critical to work with Unity:
http://answers.unity3d.com/questions/296336/timedeltatime.html
https://docs.unity3d.com/ScriptReference/Time-deltaTime.html

Bye,

 Jean

zombie

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Quaternion.RotateTowards
« Reply #6 on: March 09, 2017, 07:19:24 PM »
Can you point out where the documentation is for doing this?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quaternion.RotateTowards
« Reply #7 on: March 10, 2017, 01:19:27 AM »
Hi,

 for doing what exactly? I gave you two links explaining what Deltatime is, and how to get this delta time.

Don't overthink this :) if you still struggle, I'll do a working fsm doing exactly what that line of code does.

 Bye,

 Jean

zombie

  • Playmaker Newbie
  • *
  • Posts: 9
Re: Quaternion.RotateTowards
« Reply #8 on: March 10, 2017, 01:46:35 AM »
I know what delta time is, I use it all the time. I don't know how to use it in playmaker though. I just purchased the asset and am just learning how to use it.

Rotating something in c# is trivially easy. I'm struggling with playmaker though.

So I'm rotating  an object a total of 90 degrees while a trigger is activated. Then rotating it back when it is not.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Quaternion.RotateTowards
« Reply #9 on: March 10, 2017, 04:22:33 AM »
Hi,

 ok, I have done a test and it works fine. see below.




 Can you tell me what's different in your setup? for sure it's always best to define a quaternion using QuaternionEuler Action or based of a GameObject Transform in the world, it avoid potential gimbal lock, in which case simply use slightly off value, don't put 90, but 89.99, don't put 0, but 0.001 when you define quaternion target within QuaternionRotateTowards.

 Let me know if you want me to send this scene.

 also, for this kind of stuff, you are better off using some proper tweening engine, iTween is by default shipped with PlayMaker, and you simply use RotateTo, it's one action and it does it all for you, instead of 5 for manually quaternion manipulation.

Check this if you want to use tweening:

 http://hutonggames.com/playmakerforum/index.php?topic=14528.msg67534;topicseen#msg67534





 Bye,

 Jean