Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: vonpopov on February 02, 2014, 08:10:02 AM

Title: Get Rotation Float
Post by: vonpopov on February 02, 2014, 08:10:02 AM
Hi,

When i use the action Get Rotation and store the data into a Float Variable, i am not satisfied with what i get :

Here is an explicating image of what i expect :
(Value in blank are value stored into the Get Rotation Float)

http://oi60.tinypic.com/2u47up1.jpg

Is there someone who know how to get it like that ?
Title: Re: Get Rotation Float
Post by: Lane on February 02, 2014, 09:57:23 AM
 I'm quite sure you don't have the left image occurring, since 360 is a full rotation its not going to occur at the 180 position.

You should probably use quaternions, but you can use a couple of states to figure out which direction is in and subtract a number from it to get the value that you want. I did this once and its kind of overkill, but does work.

Look around for gimbal lock threads. On my phone atm so i cant really search.
Title: Re: Get Rotation Float
Post by: vonpopov on February 02, 2014, 10:02:08 AM
I'm quite sure you don't have the left image occurring, since 360 is a full rotation its not going to occur at the 180 position.

And this is exactly what i get , unfortunatly ... that is no sens, but it is what i get ...
Title: Re: Get Rotation Float
Post by: Lane on February 02, 2014, 10:13:37 AM
 Can you post a repro scene package?
Title: Re: Get Rotation Float
Post by: vonpopov on February 02, 2014, 11:36:35 AM
yes

(http://oi60.tinypic.com/mhtxrt.jpg)



So, basically what i just did, is to get rotation from an object (throught a get axis vector).

What i want is to know "the local degree of orientation" of my object. But actually this not go 0° to 360°, it go 360 to 270, 270 to 360, then 360 to 90, 90 to 360 (this is what is see in the inspector variable)

o__o'

help :D
Title: Re: Get Rotation Float
Post by: vonpopov on February 02, 2014, 01:39:48 PM
what is very strange, this is when i do the same test on X_Rotation (or Y_Rotation), everything fine, it goes 0 to 360 ..... but NOT with the Z axis ... what the hell is going on ?!

 :-\
Title: Re: Get Rotation Float
Post by: vonpopov on February 02, 2014, 02:03:11 PM
I maybe have an idea of the problem.

Because Y and Z are ok, not Z, i supposed the problem come from another action.

The first on the list is the Get Axis Vector.
I just realize that my object is relative to "nothing".

On most of your tutorial this is relative to the main camera. mmmm ? any idea ?


Because of course i tryed, with the father of my main camera as relative. But , rotations breaks when i hit 270° or 90°. I am close to the problem , that is sure ... even if the camera is the children of my object, the axis (horizontal/vertical) change depending on Y axis orientation. this is .. adzjklaz jk adz jkad !  :-[



Title: Re: Get Rotation Float
Post by: vonpopov on February 02, 2014, 05:05:01 PM
I am stuck.

I have no idea why , when i use "Get rotation", it gives me incorrect data on X (Y and Z axis are OK, and goes 0° to 360°), EVEN IF , my object is rotating perfectly in the 3D view.

I assume this is because i did something wrong between get axis, and rotating, BUT BUT BUT BUT , "Get rotation" shouldn't care ? no ? get rotation is just supposed to tell me what is the rotation of my object in the world ? and assuming the object is turning perfectly well, why the data in the X_Rotation float variable are crazy ? ...

 :-[ :-[ :-[ :-[ :-[ :-[ :-[ :'( :'( :'( :'(
Title: Re: Get Rotation Float
Post by: Lane on February 02, 2014, 05:53:12 PM
Can you attach a scene so I can see whats going on?
Title: Re: Get Rotation Float
Post by: vonpopov on February 02, 2014, 06:00:38 PM
Can you attach a scene so I can see whats going on?

i am not sure how to do this :s
(maybe we could catch on skype ? and share my desktop ?)

I tryed to store the euler information from my object ... and i get something very weird.

(http://oi57.tinypic.com/1073rpk.jpg)


As you can see, it seems Y and Z axis reverse to 180° with no reason when i hit 270° (same when i hit 90°). it could explain why X axis rotatin looks good in 3Dview even if the variable value looks crazy.

Title: Re: Get Rotation Float
Post by: Lane on February 02, 2014, 06:04:00 PM
Assets>Export Package, then choose the relevant scene/parts. Don't include PlayMaker in the package. That'll export the package into a file, which you can attach here.

I can't really tell whats happening from the pics, looking at the scene myself would help.
Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 04:13:50 AM
Yes ok,

but before doing this, i am asking to myself if i did something wrong with my world orientation.

My vehicle local axis are oriented like this :

Z : Forward
Y : Top
X : on the right

And, my vehicle is oriented on the world the same way


What do you think ?

Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 05:47:21 AM
After some research, it seems this is not because of my local axis orientation (those are ok), and not because of my input modification.

Should it be because "get rotation" is not capable of getting the X axis correctly ?

Fact is , "Get Rotation" understand things like this :

X:180;y:0;z:0    =   X:0 ; y:180 ; z;180   

Title: Re: Get Rotation Float
Post by: jeanfabre on February 03, 2014, 06:31:02 AM
Hi,

 I agree with Lane, you need to use quaternion, you are facing gimbal lock issues, you can't express reliably a rotation using euler angles, they are good for a very large number of needs, but not for everything.

 store your rotation as a quaternion and then extract what you need form there.

there is also a set of custom action that you will likely find useful to work with quaternions.

https://hutonggames.fogbugz.com/default.asp?W967


The question really is what do you want this value to be? what does that represent actually?


bye,

 Jean
Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 07:14:19 AM
you both are godamn, right. This is all about quaternion and gimball lock.

I just watched a 8 minutes movies on youtube, but as english is not my native language, i missed a lot of things, and not understand everything even if i understood this was clearly my problem.

I imported the quarternion package (also i don't understand why this is not already included into the playmaker package), and tryed some action.

But i am f**** lost ahah. I have no idea what to do with. All i know, is :

X and Z are my Horizontal and Vertical and i want them to rotate freely. (+ Z is my forward).

So i guess, i need to tell quarternion to LOCK Z and Y when X get to 270° and 90°. Is there any playmaker tutorial in that way ?

Thanks you for your support both :)
Title: Re: Get Rotation Float
Post by: jeanfabre on February 03, 2014, 07:23:39 AM
Hi,

 The question is , what do you want to do with this value? what does that mean in your project?

You can't lock axis with quaternions... also, you can't have two freely rotating axis without all axis being free... It's either a pivot around one axis or a totally free rotating body.


bye,

 Jean
Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 07:43:26 AM
Hi,

 The question is , what do you want to do with this value? what does that mean in your project?

You can't lock axis with quaternions... also, you can't have two freely rotating axis without all axis being free... It's either a pivot around one axis or a totally free rotating body.


bye,

 Jean


I am working with a plane controller. Actually this perfectly works in 3D view, but as i wanted to add some more effect, i saw my data on certain axis were "not" the way i needed to go further. More, the following camera was occuring problem when i hit verticals 90° or 270° (when doing a looping up or down).

So i realized, that my X axis (which represent the axis in order the plane do a looping) didn't go 0° (start position) to 360° (full looping). My X axis was going crazy when hit x:270, because  Y and Z get to 180 instantaneously.


look here :

(http://oi57.tinypic.com/1073rpk.jpg)

This is what i don't want. I want X to go throught 270 and Y+Z not doing anything.

:)

tips : i am sur it has to do with "quaternion euler" action
Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 11:02:38 AM
i got a look on other topic in the forum about gimball lock, quaternion. But (even if i barrely not understand because i am definitively a designer and math are out of my mind)

here is what i am doing (if i remove all the rest):

(http://oi42.tinypic.com/515zcj.jpg)

Get vector, increment +3 , or decrement -3.
How is that possible that everything gone wrong for X when hit 270° and 90° ? shouldn't it be supposed to rotate the same way than Y and Z ? I mean just adding 3 or substracting 3 ... nope ?

 
Title: Re: Get Rotation Float
Post by: Lane on February 03, 2014, 11:18:41 AM
That should rotate the object just fine, without gimbal lock.
Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 11:30:33 AM
That should rotate the object just fine, without gimbal lock.

i did a video, you'll see i am not crazy, it didn't work.

http://www.ww2airsoft.fr/popov/playmaker.mp4
(take a look at the quaternion value i register, which is the same as euler by the way. At first i was just monitoring X as float, and did not understand why those crazy value, until i catch Y and Z axis doing 180° for no reason)




More , if i chose to modify the Get axis vector with a "relative to camera" (camera children of the aircraft), then ... x rotation litteraly BLOCK at 270° (up) , or 90° (down).


And as you can see the aircraft is turning perfectly in the 3D view, but in fact at a time eye cannot catch, it flip 180° on Y and Z , so ... it makes it impossible to use correctly for the next steps of my project, i need a proper X rotation 0 to 360 (that i should have basically).


48h stuck on that dklajzdalzdjadjaza ! god i miss my pencils ahah "HELP"
Title: Re: Get Rotation Float
Post by: Lane on February 03, 2014, 11:43:41 AM
At first i was just monitoring X as float, and did not understand why those crazy value, until i catch Y and Z axis doing 180° for no reason)

There's nothing incorrect in those values, that is simply a correct rotation.

Quote
More , if i chose to modify the Get axis vector with a "relative to camera" (camera children of the aircraft), then ... x rotation litteraly BLOCK at 270° (up) , or 90° (down).

If your camera is the child of the object you're moving relative to your camera then that could be a problem. You have a dependency loop.

Quote
And as you can see the aircraft is turning perfectly in the 3D view, but in fact at a time eye cannot catch, it flip 180° on Y and Z , so ... it makes it impossible to use correctly for the next steps of my project, i need a proper X rotation 0 to 360 (that i should have basically).

What does this break, specifically? Rotations are always represented this way at a root level so the question is really how to identify what function you have that is broken by this and find a way around it. That generally just means using Quaternions instead of Euler angles.
Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 11:58:12 AM
ooooooow .... ok ok.
So, 48h going crazy for nothing, because that flip on Y/Z is normal representation ? (http://t0.gstatic.com/images?q=tbn:ANd9GcRPT6at4mmvXHle1a-cD-2TliI6j544facMbfSX14zWfTzGQqvcEHoULg)

But why when rotating only Z or Y , i get a perfect 0° to 360° ?


You ask for what kind of function it breaks, ok the first one is :
07 - First and Third Person Cameras tutorial.

I did it, the camera follow perfectly, zoom in/out very well, but when i am doing a 360 turn on X, at the verticals, the camera get crazy (because of the itween rotate update as a delay it show obviously the problem of camera having trouble to know where it should be positionned during half a second).

:s


nb : again, thanks for you help :) :)


Title: Re: Get Rotation Float
Post by: Lane on February 03, 2014, 12:11:17 PM
Try using Late Update.

Since the tutorial is built around a much more simplistic environment and you're looking for complete rotational flexibility in any direction you will probably need to cater and customize your stuff to suit your specific application.
Title: Re: Get Rotation Float
Post by: vonpopov on February 03, 2014, 12:17:06 PM
Try using Late Update.

Since the tutorial is built around a much more simplistic environment and you're looking for complete rotational flexibility in any direction you will probably need to cater and customize your stuff to suit your specific application.

i tryed late update, unfortunatly, no changes.

But i get it. I see what you mean. Could you point me a random playmaker asset (i found barrely nothing on the forum about quaternion) using Quaternion ? or some tutorial ? because the page with the quaternion action is not that easy to my comprehension. (https://hutonggames.fogbugz.com/default.asp?W967)

I am not sure to understand how it works. To me, this is a way to "detect" some angle combinaison, and "act" on that angle in real time. But i am not sure to understand.

I would try to improve the camera (from that tutorial) with quaternion in order to avoid the actual glitchs. Maybe detecting when the rotation hit 270° / 90° and tell the camera what to do.

But as i am not sure from what to start, if could point me some clues, or action set that would be usefull it could be a great start to me.

thanks
Title: Re: Get Rotation Float
Post by: Lane on February 03, 2014, 12:34:02 PM
Quote
i tryed late update, unfortunatly, no changes.

worth a try ;)

Quote
But i get it. I see what you mean. Could you point me a random playmaker asset (i found barrely nothing on the forum about quaternion) using Quaternion ? or some tutorial ? because the page with the quaternion action is not that easy to my comprehension. (https://hutonggames.fogbugz.com/default.asp?W967)

You're not alone in this boat! There isn't much info on learning quaterion use, I got a vague idea of how they work by studying the Unity Scripting Reference, looking at gimbal lock threads on the Answers page and just experimenting.

Quote
I am not sure to understand how it works. To me, this is a way to "detect" some angle combinaison, and "act" on that angle in real time. But i am not sure to understand.

I would try to improve the camera (from that tutorial) with quaternion in order to avoid the actual glitchs. Maybe detecting when the rotation hit 270° / 90° and tell the camera what to do.

The problem you're seeing is coming from setting the rotation explicitly. If you do something intuitive like a Look At + Move Towards thing with some balancing involved then you will not see the glitch, Unity will just interpolate the rotations properly because its not required to force specific rotational values in, generic and unrelated to the rotation. I intended to do this at some point but ended up going with a full First Person view. There are some free Following scripts available in various kits that you may be able to derive some ideas from their code.

Personally, I avoided this in Brevis flight by using Physics and adding force so I don't have any concerns about the angles or rotations. If you're in atmosphere then you can get the position/rotation wrt world for an up angle. I had a gyro done by just setting the rotation to 0,0,0 per frame wrt World... Ship moves - gyro inside stays level. Little tricks like that are a facade to reality that saves you a lot of time figuring out more complex stuff.
Title: Re: Get Rotation Float
Post by: jeanfabre on February 05, 2014, 04:57:03 AM
Hi,

 Sorry, I can't make sense of this. what behavior do you want to achieve?

bye,

 Jean
Title: Re: Get Rotation Float
Post by: Lane on February 05, 2014, 06:45:46 AM
Hi,

 Sorry, I can't make sense of this. what behavior do you want to achieve?

bye,

 Jean

It looks like he wants to rely on rotation to return an angle for some things, but at some point Unity will sometimes arbitrarily change or invert axi during a rotation and even though they're correct it will cause glitches.

At least thats what it looks like to me.
Title: Re: Get Rotation Float
Post by: jeanfabre on February 06, 2014, 06:22:58 AM
Hi,

 Yep, but what I don't get is the finality of that need. I need to know what the actual behavior is and then I can provide a working sample or something.

Is it for example to control a spacecraft by rotating the gameobject on two axis? is it to aim at something like a turret? etc etc

bye,

 Jean