Hello! I’m trying to add crouching to my FPS game, but I have one problem: when I use RayCast3D node (I tried ShapeCast3D, but it ignores collisions) to prevent player from standing up under low object all works fine, except one thing: if I stand close to low object, hold “W” key and press “crouch” for a small time, my player starts to bug out (clipping into the wall). Can someone tell me better way to make crouching? Currently I use animations in AnimationPlayer node (crouch, uncrouch). Also tried enabling/disabling two different collision shapes, same problem.
@GodofGrunts you’re exactly right about what I’m doing. I’m blanking on a more clever way to handle this, do you have any suggestions?
var speed = SPEED
if Input.is_action_pressed("Crouch"):
speed = CROUCHSPEED
if !crouched:
$AnimationPlayer.play("Crouch")
crouched = true
else:
if crouched:
if not $HeadRayCast3D.is_colliding():
$AnimationPlayer.play("UnCrouch")
crouched = false