0 votes

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?

in Engine by (16 points)

1 Answer

+2 votes

Hello,

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

Check here

by (1,817 points)

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.

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.

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.