Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

9 years ago by netmute

Hi everyone!

I'm working on a little procedurally generated platformer. Because of the randomly generated endless level style, I had to use entities instead of collision tiles.

The player collision box is about 8x3 pixels in size. Now I have a game mechanic where the player can duck and skid beneath obstacles. To allow for this, I had to correct the collision box size to 3x8 pixels.
But then the animation seems to jump out of place, so I set offset and position accordingly to make the effect look smooth.

And there is my problem. The world consists of 8x8 pixel block entities, which I place next to each other to build platforms. Because I have to change the player position when the animation changes, there is this weird corner case where the player gets stuck in between two of these boxes that are right next to each other.

The result is that the player seemingly collides with thin air once in a while, which is really annoying.

For the last 2 days I was trying to fix that. The result is a million 'if' statements all over the place just to correct the failing collision detection.
It's driving me insane, there has to be a more elegant solution to this.

Has anyone build something similar and can help me?

9 years ago by mglnunez

I can tell you that you could have used the collision map for this. Check out Drop and it's source code in the documentation.

I not sure what the problem could be.
I'm assuming that you are moving the y position down by 5 (+5). If you did that i don't see why it wouldn't work as if you were just running normally.

Use the impact debugger and turn on the collision boxes for the entities that should show you if the positions are off.

If you are still stuck post some code so we can poke some holes.

9 years ago by netmute

Thanks for pointing out the collision map! I wasn't really sure if it is flexible enough. Will definitely look into it.

Maybe it's a bit easer to follow my ramblings with an actual example :)
Here's the game in it's current form: http://demo.simonernst.com/

I noticed that, if the player entity just runs long enough, it collides with the floor, without the player interacting with the game. So no offsets/positions are changed. Which makes me believe that it isn't actually something my code did, but Impact itself.

Maybe using entities for level generation just isn't the right way to do it.

9 years ago by mglnunez

I played your game a few minutes, I couldn't get the bug with just running and colliding into the floor.

I did notice 2 bugs with the sliding and/or the little jump after sliding.

1) If you stop sliding while under the thin platforms you pop over the platform if there are no blocks above it.

2) If you stop sliding and you are right below some blocks there is a chance that the little jump will get you to collide with the blocks above.

I thought up of a possible solution to colliding mid-platform.

Basically when you generate the platforms, generate an invisible platform (just for collision) with size that spans the length of the visible platform and place it in the same position of the first tile in the platform.

For the floor it's better to use the collision map and generate the floor as the player moves.
Page 1 of 1
« first « previous next › last »