0 votes

I've created a TileMap using a TileSet and successfully created a map using one of the
official tutorials. I've also created a player sprite with a KinematicBody2D and a CollisionShape2D with a capsule shape. The problem is that when I move the character using the arrows, it gets stuck in between the tiles and on top of the slopes, which makes it completely unusable.

This is the code: https://pastebin.com/mv1gv7Xq

Any ideas? Thanks.

EDIT: I tried using a rectangle shape for the collider and it works perfectly, but now I'm confused. Shouldn't the capsule work better, as it's rounded? Circles don't work either.

in Engine by (18 points)
edited by

Capsule is not better, is different (personally, I prefer rectangles because they get simple normals).

Check the normals when the capsule stop moving, maybe is a gap and you are not controlling that situation.

And if on 2.1.3+, be sure to turn on Project settings>Physics 2D>motion_fix_enabled, that will solve some issues when sliding.

1 Answer

+1 vote

"it gets stuck in between the tiles and on top of the slopes, which makes it completely unusable."

This usually happens when you have inaccurate collision polygons on your tiles, which creates gaps between tiles. Make sure to enable snapping, and ensure your polygon vertices are exactly where they need to be.

by (1,326 points)

I used snapping when editing the colliders, but I checked just to be sure and they were correctly aligned, so I don't know what could cause it. I'm using a rectangle shape now and that seems to works correctly, so I don't care as much now. But thanks anyways!

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 Frequently asked questions and 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 [email protected] with your username.