Jump only on the tops of platforms

SparkyidrSparkyidr Member Posts: 2,033
edited November -1 in Working with GS (Mac)
so...
I'm making a platform game kind of thing, and I have my player colliding with some floors, and only jumping when he is colliding with the floors.
And I have been trying to find a simple way where he can only jump if he is touching the actual top of the floors, not the sides or anything.

So I guess I have to get some kind of check in there to see where he is in relation to a floors Y value or something....but my tiny brain is having trouble finding a simple and tidy solution.
Every time I think I have come up with a solution, I think of a way it's not going to work.

Anyone point me in the right direction?

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    not sure if im understanding what your tring to do. You can put a invisible actor just along the top of the platform and not on the sides. then when the player collides with that actor change a attibute to true and only apply jump rules if the attribute is true. Is that like what your trying to do?
  • simo103simo103 Member, PRO Posts: 1,331
    don't know if the doodle jump like action will help you but scitunes has a good template of that if you search 'jump through' when you open GS and +NEW
  • SparkyidrSparkyidr Member Posts: 2,033
    Nah.. not doodle jump. I know how to do that.

    It's more like a traditional platform game....imagine say, Manic Miner or something.

    I did think about having a thin (couple of pixels) actor stuck on the top of the main platform actors I have, but that seems like a lot of faff, and basically doubles the amount of actors per scene.

    I'm guessing there is a way using attributes to check if the players Y value is a certain amount of pixes above the Y of the platform, and only allowing the jump to happen then.

    As it is at the mo, if I hit the side of a platform, and hit jump, he sort of jumps, and cllimbs up the side of the platform.

    hope that makes sense.

    Am pretty sure I saw a vid on here (I think it was one of the free templates that was included with the canabalt style template) showing exactly what I am on about....but with it NOT happening. ;)
  • HachikoHachiko Member Posts: 330
    Mainly, you want self.canJump to be true when player collides with floor and his Y position is > of Y position of the block, plus self.size.height*0.5 of the block, plus a little less than player size height * 0.5. That's actually the same thing you do for killing enemies if you jump on their head, you compare the Y.
    That's the start, then you have to wrap your head around making it work more efficiently and never fail the check, even if the player is touching for example a block floor with his feet and another with its side (which should make canJump false).
  • SparkyidrSparkyidr Member Posts: 2,033
    Yeah, thats kind of what I thought really.

    Just a bit of a pain in the arse when there are a lot of "floor" instances in a scene.
  • expired_012expired_012 Member Posts: 1,802
    I actually have a demo saved for this. I think it may have been made by toastkitten. If you want it pm me your email or just email me at artonskyblue@gmail(dot)com and ill send it over to you :)
  • SparkyidrSparkyidr Member Posts: 2,033
    @arton

    Cheers

    just dropped you an email.

    niceone.
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    it made no sense, what I wrote, so edited it out :-P
  • SparkyidrSparkyidr Member Posts: 2,033
    This is starting to fry my brain right now.

    I get the theory.
    (check the Y value of the player, with the Y value of a platform, and only jump if the Y value of the player is a certain amount above the Y value of the platform)
    I can get the theory to work for a single platform in a scene.
    (it's obvious and straightforward)

    My brain then explodes as I try to factor that up to a scene with 20-30 platforms, and multiple scenes.

    :o(
  • Falcon636Falcon636 Member Posts: 5
    Have you come to anything yet? I'm making a game where platforms are spawned and move to the left, while your character can only jump on the spot- giving the illusion of movement. This means whatever solution I come up with so that the player can ONLY jump from the tops of platforms, will have work when the platforms are spawned randomly, and immediately move across the screen...

    Thanks! ^^'
Sign In or Register to comment.