Logic problem

StoopieSteveStoopieSteve Member Posts: 9
edited August 2013 in Working with GS (Mac)
I have a game attribute for an object A with X velocity that is always changing depending on a key board input.

I have a separate object B that I am trying to precisely place on screen between two X points.

I want that object to move to X point a whenever velocity is increasing and X point b whenever velocity is decreasing.

I am trying to figure out the right condition for this event.

Does anyone know how to reference the change in velocity or distinguish between acceleration and deceleration?

This is pseudo code but its sort of what I am after:

If A.Xvelocity = A.Xvelocity++ then ease object B to X point a.
Or if A.Xvelocity = A.Xvelocity-- then ease object B to X point b.

Any thoughts?

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited August 2013
    Well basically you're looking to create a sliding scale. So we'd need to establish the minimum velocity and the max velocity. Then we need to establish the minimum X position and the maximum X position. Armed with that info one could determine the best operator to use for the translation between the two types of data. So say your starting X position is at 100pix and your ending is at 600pix and your minimum velocity is at 0 and max is at 500. One could constrain the position of actor B to actorA.linear.velocity.X + 100. See where I'm going?
  • StoopieSteveStoopieSteve Member Posts: 9
    Thank you very much for responding!

    That makes perfect sense actually, I don't know why I did not think to constrain the position to the velocity...

    My brain was sizzling last night and I knew it was something that simple.

    Thanks again, your awesome!

  • StoopieSteveStoopieSteve Member Posts: 9
    That was it... I just had to come back and say thank you again. That definitely helped me get the solution I wanted. It took some more tweaking and a little math to get exactly what I was going for but that constraint was the missing piece of my puzzle.

    So, thanks again, you rock!
Sign In or Register to comment.