GameSalad

jumping below platform, how can i prevent this?

njvdberge%40gmail.comnjvdberge@gmail.com Indie Game DeveloperBreda, the NetherlandsPosts: 22Member

Hey there,

i am making an endless runner, to get less collision bugs i used this tutorial to collide with the spawning platforms:

it calculates for me the 5 bottom pixels of my char and the 5 top pixels of my platform.
when my player collides with my platform(so from the side of below) the player starts falling.
when the 5 pixel row of the player and the platform are = or > of each other the platform collides with my player.

but heres my problem, when i fall and my players top still collides with my platform even if youre almost below the platform and if you press you still can jump and save yourself.
how can i prevent that my player can jump even if im below the platform?

Answers

  • Happy+Family+GamesHappy Family Games Posts: 25Member
    edited March 2015

    I would set up an attribute that tracks the platform's position in y and set a rule so if the player's position is below a certain threshold (I'm assuming 5 px in your case) then the player can't jump.

    I would set up a real attribute called platformY or something similar. Go into the platform actor's backstage and constrain his position in y to platformY:

    constrain game.platformY to self.position.y

    then go into your player's backstage and set a rule keeping your player from jumping when he's below that position

    Rule
    attribute: game.platformY > self.position.y -5
    do: change attribute game.jump false (or however u have it set up)

    I'm not sure if this is the most efficient way, but it should work.

    P.S. check my equation for errors such as < instead of > or + instead of - I usually have to experiment before I get it right lol

    As far as collision problems, are your platforms moving? I always run into trouble with moving collidable objects and the player falling through them... not sure why but maybe somebody can shed some light on this if yours are moving

    Edit: if there's more than 1 platform on screen at a time this could prevent the player from jumping at all... not sure what to do in that case

  • njvdberge%40gmail.comnjvdberge@gmail.com Indie Game Developer Breda, the NetherlandsPosts: 22Member

    i tried your solution. but it didnt work. i tried all different combinations with < > -+ false true. but it didnt work.

  • Happy+Family+GamesHappy Family Games Posts: 25Member
    edited March 2015

    Is there more than 1 platform on screen at a time? If so, that setup wouldnt work

    Also, if there is only 1 on screen at a time and you don't have the platforms destroy themselves offscreen then it's the same as having multiple platforms on screen

Sign In or Register to comment.