Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: zombie on March 06, 2017, 10:43:03 PM
-
I'm rotating an object. In a script, I would use the following.
transform.localRotation = Quaternion.RotateTowards(transform.localRotation, objectEndRotation, Time.deltaTime * rotationSpeed);
In Playmaker, I got the same job done with:
(https://image.ibb.co/egv4Qa/Screen_Shot_2017_03_06_at_7_36_27_PM.png)
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?
-
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
-
I have no idea how to multiply it my Time.Deltatime.
-
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
-
Would this do the job?
(with Every Frame checked on the bottom)
(http://i67.tinypic.com/s2v5l2.png)
-
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
-
Can you point out where the documentation is for doing this?
-
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
-
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.
-
Hi,
ok, I have done a test and it works fine. see below.
(https://dl.dropboxusercontent.com/u/17356625/Unity/PlayMaker/QuaternionRotateTowards.gif)
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
(http://i.imgur.com/p8UgQCM.gif)
Bye,
Jean