Step up small obstacle | Kinematic 2D platformer

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By K1ll3rM

How can I handle stepping up a small obstacle using Kinematic2D based movement? I’m using MoveAndSlideWithSnap() for the movement. I’d prefer an answer based in c# but GDScript is fine as well.

:bust_in_silhouette: Reply From: kidscancode

What exactly do you mean by “small obstacle”?

If you have an uneven surface and your rectangular collider is getting hung up on small bumps, etc., what many games do is add a rounded collision shape at the feet of the player, allowing it to “glide” over them.

It would be too large to just glide over with rounded edges though that is something I’ve going to do. They would be things like real stairs, sure I could turn it into a slope but physics objects like a ball would behave differently. I’m also using a tile system and want to be able to walk up 1 tile without jumping.

K1ll3rM | 2020-10-04 20:10

couldn’t you make the stairs have a slope collision for the player, and a stair step collision for the ball? That could be done with collision layers couldn’t it?

Millard | 2020-10-05 00:53

@Millard I guess if there’s no other way, doing that with autotiles will be awful though

K1ll3rM | 2020-10-05 08:08

You never mentioned you were using autotiles. that could be tricky, to say the least. :[

Millard | 2020-10-05 17:39

I didn’t really think it would be relevant, I’m thinking about using raycasts to do it instead

K1ll3rM | 2020-10-05 18:04