playMaker

Author Topic: Ship going up or down...  (Read 3098 times)

broesby

  • Playmaker Newbie
  • *
  • Posts: 14
Ship going up or down...
« on: December 28, 2013, 08:16:04 PM »
First time here... ;)

I need to know if my flyer is going UP or DOWN in the air / in space so to speak - in my case UP-DOWN is the Y-axis.

It seems SOO simple but I can't for the life of me figure it out.

I need a state OR boolean to change whenever SHIP changes from up to down or opposite. Problem is I cannot figure out how.
I tried two times Get Position with a wait in between for time passing and then a Float compare. It doesn't work.
I also tried making a boolean change whenever rotation of ship changes from pointing up to down - not really correct logically, as a force could go in the other direction while the tip of my flyer points up - but could work in my case as not many external forces apply.... Problem is IT DOESN'T---- Cry!!

Plz help... Sincerely Jesper, Denmark  ;)

bizilux

  • Full Member
  • ***
  • Posts: 171
Re: Ship going up or down...
« Reply #1 on: December 28, 2013, 10:23:55 PM »
this should work...

broesby

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Ship going up or down...
« Reply #2 on: January 01, 2014, 04:06:53 PM »
Hi,... Thanx a lot for the answer. I tried your solution.
I am afraid it only checks if the ship passes a specific level = position.y=0.

I need the same functionality but where position.y is compared with position.y a split second or a frame ago.

I tried a lot of stuff comparing variables with short waits in between. But I always end up with maximum loop overrides ... or nothing  >:( Cry,.. this is really getting to me.

I even tried tried a concept where a boolean variable change every time the ship changes direction... same result.

My real problem comes from the fact that Get Rotation returns a number which is  0 when horizontal (actually 270 because my shipmodel comes from blender) and then the same positive number NO MATTER if the nose is pointing up or down - it seems to only care about angle - not compared to horizon.

Isn't there a parameter that is positive when nose is up and negative when down? I wonder if I need to learn how quarternions work??

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Ship going up or down...
« Reply #3 on: January 02, 2014, 05:27:57 AM »
Hi,
 
The procedure should be as follow:

Compare the current position with the last position, if y is positive then it's going up, if y is negative, it's going down.

 Don't use any waiting or tricks, it's actually very simple.

I have attached a working sample, with two different execution of the procedure, one where it compares every x seconds, and another one where it switches states instead. The second one means duplication of comparision procedure, but that can also be optimized if an fsm is only responsible for getting the delta movement. But I did not wanted to complexify the example.

Bye,

 Jean

broesby

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Ship going up or down...
« Reply #4 on: January 06, 2014, 06:25:01 PM »
Sorry for not answering. My wife is VERY pregnant so not much time for Unity these days  ::) :)

Thx, Jean. That really helped a lot. Almost solved my problem. Now I do know if my ship is going up or down indeed...

But I have to correct myself. Actually what I need is to know if my ship is POINTING up or down  ::) I tried all Get Properties involving rotation I think  :o

If i use rotation.x or up.x or something like that it works but only as long as I dont turn my ship around and go in the other direction.

If I use euler angles it flips around zero - zero being horizontal. Which means I cannot decide if ship is pointing up or down. Only that it is not level... horizontal.

Isn't there any value thats simply positive if ship is pointing UP and negative if DOWN? Compared to the world. In any direction of the ship...

I simply CANNOT get my head around this one... Sorry.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Ship going up or down...
« Reply #5 on: January 07, 2014, 04:26:02 AM »
Hi,

 For this, two different options:

 Find out the signed angle between the horizon and your ship using this action:

http://hutonggames.com/playmakerforum/index.php?topic=3027.msg13819#msg13819

 or, get the forward axis from your ship ( using "Transform Direction" Action )and use its y value and check if it's positive or negative ( Pointing Up or down)

Bye,

 Jean

broesby

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Ship going up or down...
« Reply #6 on: January 07, 2014, 06:41:16 PM »
That did it ;) You are a genius, Jean :) Thank You..

My ship can now free fall when pointing down .... Nice.

Next problem is to limit or dampen ship rotation in a way to keep me mostly level with the horizon also when I turn around a lot. The ship always end up flying sideways  >:( I searched this forum and Unitys and see that I'm not alone. Didn't find a vialble solution, though.

Working with angles/rotations is really hard.

It doesn't help to constrain rotation as it goes awry when ship goes up or down. I tried setting rotation limits and "itweening" them back to level.. Cannot get that to work...

Sry for being such a pain  :-[

phannDOTde

  • Full Member
  • ***
  • Posts: 237
    • Peter Hann .de
Re: Ship going up or down...
« Reply #7 on: January 08, 2014, 07:04:16 AM »
Maybee you could try to Clamp the max Values. I do that with positions.
Get Pos
Clamp Pos
Set Pos

So everytime the Min/Max is reached it makes sure it clamps to tha min/max Value and overwrites the actual Pos. Not sure if that helps here.