In my (first) project in Godot, a simple platformer, I wanted to have the character slide. When the character slides, he should only be one tile tall so he can fit through smaller gaps. Because I didn't know any better solution, I changed the hitboxes like this:
(Also I used a seperate hitbox for walking)
enum Shape {
NORMAL,
WALK,
SLIDE
}
func set_shape(name):
$NormalCShape.disabled = true
$WalkCShape.disabled = true
$SlideCShape.disabled = true
if name == Shape.NORMAL:
$NormalCShape.disabled = false
elif name == Shape.WALK:
$WalkCShape.disabled = false
elif name == Shape.SLIDE:
$SlideCShape.disabled = false
This isn't a very nice solution. Recently, my code got more complicated because I added different gravitational directions, which would result in 12 different hitboxes. I haven't found any better solution to do this, but I feel like there's got to be one.
So can anyone help me with this?
gravity
collision shape that stays the same but doesn`t collide with objects? – magenulcus