Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | daaviid9 |
Hello
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: https://streamable.com/h92mv3
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
else:
motion.x = 0
motion = move_and_slide(motion, UP)
daaviid9 | 2022-02-25 15:13
Hey,
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:
https://forum.godotengine.org/123115/merge-collision-shapes-to-one-big-rectangle
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