Jump only on the tops of platforms
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?
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
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.
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).
Just a bit of a pain in the arse when there are a lot of "floor" instances in a scene.
Cheers
just dropped you an email.
niceone.
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.
Thanks! ^^'