Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: nFighter on August 19, 2017, 01:42:48 PM

Title: get local Rotation
Post by: nFighter on August 19, 2017, 01:42:48 PM
Looks like a simple question, but I stuck. How can I get the local rotation of the object like it is shown in the inspector? For example it rotates from -10 to 10, how can I just get this numbers, instead of all this eulerquaternionstuff
(https://snag.gy/RIUwBQ.jpg)
Title: Re: get local Rotation
Post by: djaydino on August 19, 2017, 10:51:52 PM
Hi,
"Get Rotation" action?

Btw.
You should try to avoid using get/set property.

if you can't find certain action, there is a big list of actions on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) :)
Title: Re: get local Rotation
Post by: nFighter on August 20, 2017, 08:44:45 AM
Is get/set property so bad?

But even with Get Rotation I can't obtain this result  :-\
(https://snag.gy/4mAN1c.jpg)
Title: Re: get local Rotation
Post by: djaydino on August 20, 2017, 09:54:03 AM
Hi,
i think you need to set 'Space' to "world"
Title: Re: get local Rotation
Post by: nFighter on August 20, 2017, 11:18:41 AM
No way.  "world" showing me the rotation relatively to the world, so it's inherit all the rotations from the parent objects and show 0..360 angle relatively world x-axis.

Self mode is correct, but  it can't give me -10 value (like it shown in the inspector), instead giving me 350.

And it's very frustrating, because I can't simply remap value (-10..10) in one action. It's jumping from the 0 to 360 and back.
Title: Re: get local Rotation
Post by: tcmeric on August 20, 2017, 11:22:23 AM
I actually had this same problem a bunch of months back (was working a small VR game). Let me take a look into it again now that my C# is a bit better.
Title: Re: get local Rotation
Post by: nFighter on August 20, 2017, 11:30:07 AM
Great, thanks! Looking forward to see your results!

I wonder, is it really not a common task, so there is no common solution out of the box?  ???
Title: Re: get local Rotation
Post by: nFighter on August 20, 2017, 12:03:54 PM
So, as I understand, basically people use solution like:
if (x > 180)   x -= 360;

Isn't it weird? I see the negative values right in the inspector with my eyes, why can't I just get it directly like it shown?  :o

And obviously I can't make it in one FSM state and need to make a networks of checks and transitions?
Title: Re: get local Rotation
Post by: nFighter on August 20, 2017, 12:34:58 PM
OK, I made my own action for negative values of local rotation. If someone else need it - here it is

https://www.dropbox.com/s/9zoeion5oh8m700/GetNegativeRotation.cs?dl=0 (https://www.dropbox.com/s/9zoeion5oh8m700/GetNegativeRotation.cs?dl=0)
Title: Re: get local Rotation
Post by: djaydino on August 21, 2017, 01:16:32 AM
No way.  "world" showing me the rotation relatively to the world, so it's inherit all the rotations from the parent objects and show 0..360 angle relatively world x-axis.

Self mode is correct, but  it can't give me -10 value (like it shown in the inspector), instead giving me 350.

And it's very frustrating, because I can't simply remap value (-10..10) in one action. It's jumping from the 0 to 360 and back.

Sorry, i did not check properly. (was working on 3 project @ the same time)
Title: Re: get local Rotation
Post by: jeanfabre on August 21, 2017, 02:18:02 AM
Hi,

 yes, the Transform component inspector is processing the euler angles, so getting the exacty same values means fiddling around. 350 is the right value, -10 is a processed value and it's not available form the transform rotation directly.

 Bye,

 Jean
Title: Re: get local Rotation
Post by: jeanfabre on January 10, 2019, 03:53:20 AM
Hi,

 I just put that action on the Ecosystem for convenience.

 Bye,

 Jean