From 3a3340ed887a2f81172d3e3d8a51d9d5613a0829 Mon Sep 17 00:00:00 2001 From: KirbyKidJ <70983335+KirbyKid256@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:46:09 -0700 Subject: [PATCH] Prevents small crouch if it's not a used animation Also added some functions for debugging and toggling visible collisions. Also fixed some inconsistencies with both small and big collisions. --- Scenes/Prefabs/Entities/Player.tscn | 3 ++- Scripts/Classes/Entities/Player.gd | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Scenes/Prefabs/Entities/Player.tscn b/Scenes/Prefabs/Entities/Player.tscn index 54661da..c7b80ab 100644 --- a/Scenes/Prefabs/Entities/Player.tscn +++ b/Scenes/Prefabs/Entities/Player.tscn @@ -711,7 +711,7 @@ position = Vector2(0, -13) collision_layer = 0 collision_mask = 384 -[node name="SmallShape" type="CollisionShape2D" parent="LavaPoisonDetect"] +[node name="SmallShape" type="CollisionShape2D" parent="LavaPoisonDetect" groups=["SmallCollisions"]] position = Vector2(0, 5.75) shape = SubResource("RectangleShape2D_uwhl4") debug_color = Color(1, 0, 0, 0.419608) @@ -1057,6 +1057,7 @@ script = ExtResource("35_nbkfn") [node name="BigCollision" type="CollisionPolygon2D" parent="." groups=["BigCollisions"]] visible = false polygon = PackedVector2Array(-4, -2, -2, 0, 2, 0, 4, -2, 4, -23, 1, -28, -1, -28, -4, -23) +one_way_collision = true script = ExtResource("35_nbkfn") [node name="FootL" type="CollisionShape2D" parent="." groups=["StepCollision"]] diff --git a/Scripts/Classes/Entities/Player.gd b/Scripts/Classes/Entities/Player.gd index 4698ebf..caf91db 100644 --- a/Scripts/Classes/Entities/Player.gd +++ b/Scripts/Classes/Entities/Player.gd @@ -59,7 +59,10 @@ var total_keys := 0 set_power_state_frame() var character := "Mario" -var crouching := false +var crouching := false: + get(): # You can't crouch if the animation somehow doesn't exist. + if not sprite.sprite_frames.has_animation("Crouch"): return false + return crouching var skidding := false var can_bump_sfx := true @@ -137,6 +140,7 @@ const ANIMATION_FALLBACKS := { "Run": "Move", "PipeWalk": "Move", "LookUp": "Idle", + "Crouch": "Idle", "CrouchFall": "Crouch", "CrouchAttack": "Attack", "FlagSlide": "Climb", @@ -456,14 +460,15 @@ func handle_power_up_states(delta) -> void: var small_crouch := power_state.hitbox_size == "Small" and crouching var big_crouch := power_state.hitbox_size == "Big" and crouching for i in get_tree().get_nodes_in_group("SmallCollisions"): - if i.owner == self: - if i.name.begins_with("SmallCrouch"): - i.set_deferred("disabled", power_state.hitbox_size == "Small" and !crouching) - else: - i.set_deferred("disabled", small_crouch or power_state.hitbox_size == "Big" and !crouching) + if i.name.begins_with("SmallCrouch"): + i.set_deferred("disabled", power_state.hitbox_size == "Small" and !crouching or power_state.hitbox_size == "Big") + i.visible = not i.disabled + else: + i.set_deferred("disabled", small_crouch or power_state.hitbox_size == "Big" and !crouching) + i.visible = not i.disabled for i in get_tree().get_nodes_in_group("BigCollisions"): - if i.owner == self: - i.set_deferred("disabled", power_state.hitbox_size == "Small" or big_crouch) + i.set_deferred("disabled", power_state.hitbox_size == "Small" or big_crouch) + i.visible = not i.disabled $Checkpoint.position.y = -20 if small_crouch else -24 if power_state.hitbox_size == "Small" or big_crouch else -40 power_state.update(delta)