Can't pass between two walls

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

I’m working on a simple top down 2D game to learn Godot.

I have a player character which is a KinematicBody2D, with a CollisionShape2D that is 32 x 32 pixels in size.

I have a wall tile that is 32 x 32 pixels in size that has a collision rectangle that is also 32 x 32 pixels in size.

The problem is if I want to walk between two walls (walls can either be above/below the player or to the left/right of the player), the player can’t pass through them as if the walls were blocking the player. I checked the x and y location of the player and it should not be colliding with the walls. Any idea how this could happen and how I can fix it?

:bust_in_silhouette: Reply From: deaton64


Maybe/could be/wild guess: safe margin in your KinematicBody2D.

Check here

Thanks that worked! Was not aware of that. Is there any reason not to set it to 0? Not sure if it will cause me any issues if I do.

Sallywag | 2020-06-04 22:22

I’ve never changed it from default. I believe it’s there to prevent a body entering a collision object and having to come back out again and creating a jittery effect on screen.
It may be that having the value low, works for you in what you’re doing, but not for other things.

deaton64 | 2020-06-05 08:19

Yeah looks like disabling it causes the player to visually move back and forth when hitting a wall.

Sallywag | 2020-06-06 22:12