Godot 4.4
Hi guys, I have this code for a Wall Slide and a Wall Jump. It works correctly with the keyboard but not with the left axis of the joystick. I have an ‘jump’ action configured. Any idea what it could be?
Godot 4.4
Hi guys, I have this code for a Wall Slide and a Wall Jump. It works correctly with the keyboard but not with the left axis of the joystick. I have an ‘jump’ action configured. Any idea what it could be?
How does it misbehave? Does it not jump? Not stick to the wall?
Sure, sorry, here’s some more info. The problem arises when I try to jump, I stick to the wall and slide smoothly. But when I hold down the Jump button and move in the opposite direction, it doesn’t jump. It works with the keyboard, but not with the joystick.
is_on_wall_only()
is pretty specific, and is_action_just_pressed
with controller/axis inputs is not ideal.
It could be any of these mixed together, pressing left on the controller means you must cross a neutral input, so you may not count as “is_on_wall” for a frame between holding right to left. If you have a right-raycast for detecting wall slides it may be better to use that, it has more give/coyote time than is_on_wall.
Try this snippet out, mostly moving ray_right.is_colliding()
check instead of is_on_wall_only
, and using a dot product to determine if the wall is facing left, with more leniency.
var wall_left: float = wall_normal.dot(Vector2.LEFT)
if Input.is_action_just_pressed("left") and wall_left > 0.95 and ray_right.is_colliding():
if Input.is_action_pressed("jump"):
# etc...
Make sure to paste code instead of screenshots