Log In  

Hi guys,

Im giving it a go making a game on pico 8, after working on Godot and C3. Im wanting to build a platform engine because I tend to use that style of movement in a ton of my games. Ive tried a few different tutorials and they all have issues. I tried the one from Nerdy Teachers and if I change the movement speed to be quick the whole system fails, and the sprites get stuck etc. Plus Ive always been taught that changing a sprites hitbox size is a no no in game dev. So I guess what Im getting at is, is there a good/easyish way to code platform collisions. Or what is the best way to handle this? I have the movement down and all that, no problem. But the collisions always have glitches. Any thoughts/help would be greatly appreciated.

Thanks so much
mintpixel

P#72751 2020-02-05 03:59

1

Hey, I just noticed your post when searching for what other projects have been based on the Nerdy Teachers platformer tutorial.

If I'm not mistaken, the collision detection method used in the tutorial uses a widely used principle called Axis-Aligned Bounding Box (AABB). You can find a lot of info and tutorials on that method online. When it comes to collisions between rectangular shapes in 2D-games, that's pretty much the way to go.

Don't worry if it takes a few different tutorials and reads, as well as a lot of practical trial and error to make collisions click for you, it was the same for me. Hope you keep on trying!

If I recall correctly, the Nerdy Teachers platformer tutorial does mention how speed affects the collision checking parameters. If you haven't watched it too many times already, I recommend rewatching / rereading parts of the series carefully and that might already give you some ideas on how to proceed.

Here's my game based on the same tutorial, with the player moving in various speeds: https://www.lexaloffle.com/bbs/?tid=37036
I wish I could recall exactly what tweaks I had to make to the collision detection for it, but hopefully looking at the code can provide some ideas. I'd love to help more if you come up with more questions on the subject!

P#73819 2020-03-11 13:18
1

One thing that can also help deal with collisions on fast-moving objects is to step through the increments of a given movement, checking for collision on the way, rather than just jumping to the new position. This way, even if you are moving fast, the collision that should happen mid-move will be caught.

P#73824 2020-03-11 16:21

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 08:09:19 | 0.006s | Q:10