1 decade 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?
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?