Kinematic body with capsule collision shape keeps getting stuck on straight ground

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

I ran into an issue where my character keeps getting stuck on straight ground. I tried using rectangle collision shape which seems to fix the problem. However I would prefer using capsule shape. Does anyone why is this happening?

Here is a video of the issue:

It doesn’t slide, it detects tiny gaps between tiles, and interprets it as being in front of too sharp slope. Show your movement code.

Inces | 2022-02-25 14:14

 extends KinematicBody2D

const UP = Vector2.UP
const gravity = 1000
const maxspeed = 300

var motion = Vector2()

func _physics_process(delta: float) -> void:

	motion.y += gravity
	if motion.y > gravity:
		motion.y = gravity

	if Input.is_action_pressed("move_right"):
		motion.x = maxspeed
	elif Input.is_action_pressed("move_left"):
		motion.x = -maxspeed
		motion.x = 0
	motion = move_and_slide(motion, UP)

daaviid9 | 2022-02-25 15:13


yeah. I also ran into that issue. Like Inces said, Godot detects the gap between the collision shapes.

I had an Idea, but I am to lazy to put it on github as feature request:

juppi | 2022-02-27 11:01

Check out move_and_slide in documentation. You can insert much more arguments than just 2. One of them is the whereabouts of the slope. You can adapt slope angle to angle of your capsule shape there, so it will work on microgaps

Inces | 2022-02-27 11:56