playMaker

Author Topic: Please Help 4- hours..cant find a total rotation value.[SOLVED]  (Read 5876 times)

forcevfx

  • Playmaker Newbie
  • *
  • Posts: 20
I have a characater riding a bmx bike, I am trying to score total rotation for y and X rotation:

Scenario. when my player enters the air, I am capturing vector3/quaterian/euler's from StartJump State and then again on Land OnCollide State.

SkyRyder http://skyryder.playmerc.com/v0_95.aspx

I need to find the total jump rotation in degrees. [Y sideways rotation / X up-down rotation]

I can see the quaterian displaying the right values in the Y variable..BUT how do I access quaterian.Y ??

My player hits a half pipe, rotates (up/dpwn/left/right).

Things I am scoring against:
Total Air Time with Trick Mulitipliers:
ie.

in air over 2 secs & y rotation > 175 < 185 | 180 ??
in air over 2 secs & y rotation > 185 < 359| 360 ??
in air over 2 secs & X rotation > 350 < 359| BackFlip ??
in air over 2 secs & X rotation > 350 < 359| FrontFlip ??

and when he passes the full rotation I set a new value Total 360's / Total Flips.

I am stuck and could really use some advice!

-p
« Last Edit: May 09, 2012, 05:42:57 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #1 on: April 18, 2012, 03:06:25 AM »
Hi,

 Working with angles is tricky.

 I think the following custom action I wrote a while back would ge the job done:

http://hutonggames.com/playmakerforum/index.php?topic=1027.0

bascially, you can spy on the angle on update and add the delta angle found to a total value variable, since this actions let's you really get the "signed" angle, you can totalize an object rotation over time properly.

Mess with this, if you have issues, I will do a working example.

 Bye,

 Jean

forcevfx

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #2 on: April 18, 2012, 10:19:16 AM »
I did run across that...so target  object can be just empty game object at 0,0,0 ??

or.. how to I set his initial start postion as the 'target game object?', he's moving and changing angles constantly..so You hit space bar . this action triggers and runs,

public FsmOwnerDefault gameObject; : my Rider
public FsmGameObject target; : ????

OK, he is in the air, he has no target, landing angle will be the target for the calculation
so during update I am getting my angle of rotation, based on what, a static object??

maby I need to look at it this way...it does not matter his start rotation value.actutally this should be zeroed out, so I can get total angle of rotation while in the air.

it sounds so simple, I have to study more about 3D rotation..local/world/euler/quaterian..not my favorite thing....

Thanks!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #3 on: April 18, 2012, 11:46:10 AM »
HI,

 the target is him as he take off really, so store theposition and direction as he takes off and this is your target to compute how much he turned in the air.

 Use a dummy gameObject for that if you want.

 I'll let you steam a bit more, ok? :) that would be too easy to give you a scene, you are very close.

one thing, when the task seems too much or too messy, create a new scene, and make the feature you want as thin and simple as you can, then you'll be able to better apply what you've just learn into a more complex scene and setup, always good to start fresh on a dummy scene, get it working, validate the process, and then apply it back, prevents messing it all up and loosing hair and motivation...


 Bye,

 Jean

forcevfx

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #4 on: April 18, 2012, 12:28:21 PM »
your right, I have created too many floats / vector3  / euler angles
all in every combination / local / world, All of these I am trying view and decipher in real time.

 (I keep thinking..slow time down you moron!!)

trying to decode 16 odd running vars (just for rotation), while trying to control my charatcer, in my full level??

quite interesting..I kinda needed this...I know the key is a [quaterian euler vector3 delta].

its just a little thing, but it is, like you said...a little tricky.

this is the most I have used PlayMaker...ever.

its great!~!
« Last Edit: April 18, 2012, 04:06:51 PM by forcevfx »

forcevfx

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #5 on: April 18, 2012, 12:54:05 PM »
ok..I thought about this some more and..(not implemented yet)

When the game object w/ rigidbody enters the OnExit (in air)
I set an empty game objects vector3 w/ my players vector 3
that now becomes the object [start rotation] while continously
monitoring the delta of Target [Player].

Then acting on that delta (change in total rotation)


we will see..
p-

forcevfx

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #6 on: April 18, 2012, 09:03:13 PM »
I can not figure this out..
he passes 0 to 180 and then goes back to 0 again.
so I place a float check at 90 and 180
doesn't work 79/179..nope..um 70 and 160..at least this hits..but to many.

ARGHHH!!!!

I feel so stupid that I can not figure out in playmaker to get this work.

I have tried every logic and conversion operator I could think of.
There is  a magic action/state/equation that I can not grasp...

I can see the numbers..they are right..

90 is 45 degrees and 180 is 90 degrees
when he reaches 180 degrees, the delta values then start moving back to zero.
so when he has done a 360, he has gone from 0->180 and back from 180 -> 0
I just can not figure out the logic behind my wanted result.

please give me a clue.

p

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #7 on: April 22, 2012, 05:44:25 PM »
Hi, and welcome to gimbal lock and other fun stuff with angles ( I hate it as much as you do :) )

 Ok, this 180° turning point is very important to grasp fully, this is mandatory...

 possible problem:it's likely that the direction vectors you are using to compute them angles are wrong as you passed the 180°, so triple check with debug lines, true gameObject dummies everywhere you need to visually see where your various vectors are, this is important.

-- try the approach of recording the delta angle: so store the last forward direction of the player, get the new direction and compute the delta angle using it's up axis, you will never have in one frame the player rotating more than 180°, so you will never have that problem then.

Bye,

 Jean

forcevfx

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Please Help 4- hours..cant find a total rotation value.
« Reply #8 on: May 03, 2012, 09:08:41 AM »
ok..I think I got it....(at least close enough for a designer :-) )

player hits the OnExit State : (he is in the air)
  Get [self] Position and Rotation of "_startRotObject" [empty sphere ]

  Set [self]  Postion of "_startRotObject"  to Player current "OnExit" (inAir) Position
(move the sphere to my position and rotation)

  Monitor the Rotation [Delta] of My current Pos/Rot now called : [target] from "_startRotObject" Pos/Rot

  Add Total [Delta] Values at FixedUpdate 30 fps / divide total vales by [69-89]??

right now, its close enough!!, I know when he does a 180/360/540, etc.front flip, back flip.


Thanks!!

Kevron

  • Junior Playmaker
  • **
  • Posts: 51
Re: Please Help 4- hours..cant find a total rotation value.[SOLVED]
« Reply #9 on: November 26, 2012, 07:23:25 PM »
Hi forcevfx,

Could you please run me through your solution one more time? I am a designer like you, and playmaker is my weapon of choice.

I follow you to the point you write about monitoring the Delta. But then I get a bit lost.

Thank you,
Kevron