Character movement bugging on top of TileMap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pipe
:warning: Old Version Published before Godot 3 was released.

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: Godot character 2D - Pastebin.com

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.

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.

eons | 2017-07-11 02:42

:bust_in_silhouette: Reply From: YeOldeDM

“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.

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!

Pipe | 2017-07-11 11:57