Looks like you're not logged in

Login or Register to continue

Lesson Q&A

Use this space for questions related to what you're learning. For any other type of support (website, learning platform, payments, etc...) please get in touch using the contact form.

  • Crouch bug with jumpingTazerrtotIf you hold the crouch button while landing from a jump the camera returns to the neck's start height, but the collision shape remains smaller. This lets you go under the low ceiling while the camera is still at standing height. I resolved this by adding the same "target_neck_height" code into the landing section like so: ```gdscript var just_landed := was_in_air and is_on_floor() if just_landed: var impact_intensity := fall_speed / max_fall_speed var target_neck_height := 0.0 if Input.is_action_pressed("crouch"): target_neck_height = _neck_crouch_height else: target_neck_height = _neck_start_height var impact_tween := create_tween().set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_OUT) impact_tween.tween_property(_neck, "position:y", target_neck_height - 0.2 * impact_intensity, 0.06) impact_tween.tween_property(_neck, "position:y", target_neck_height, 0.1) ``` then also added `set_is_crouching(false)` when jumping so the character wouldn't be crouched in the air. Also changed the jump code so that it would un-crouch while jumping, but not if the ceiling wont let it un-crouch, because that causes the camera to go above the ceiling briefly. ```gdscript if is_on_floor() and Input.is_action_just_pressed("jump"): if is_crouching: _crouch_ceiling_cast.force_shapecast_update() if not _crouch_ceiling_cast.is_colliding(): velocity.y = jump_velocity set_is_crouching(false) else: velocity.y = jump_velocity set_is_crouching(false) ``` Only thing is this also makes the landing while holding crouch look kinda soft even from high heights, which might be fine though. Also, after writing this I went and tried copy/pasting your full code for the lesson just to check if my implementation differed from yours so I had a bug you didn't and noticed some differences between the lesson and the code reference. First is it references an animation player that doesn't exist yet, and second is it added a condition to jumping that wasn't there in the lesson- the reason for the bug I found; the lesson didn't mention not allowing the character to jump while crouched. Was a fun challenge to fix though even if jumping from a crouched position wasn't intended. 3 1 Apr. 11, 2025
Site is in BETA!found a bug?