From a604c99a42fbf55dbbbd35a3dcc1069f0eb10618 Mon Sep 17 00:00:00 2001 From: Ervan Lefevre Date: Sat, 30 Sep 2023 17:47:39 +0200 Subject: [PATCH] :beers: Mitigates an issue where the player moves freely in the water --- nodes/player/player.gd | 9 ++++----- nodes/player/player.tscn | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/nodes/player/player.gd b/nodes/player/player.gd index d258bf4..ec3b468 100644 --- a/nodes/player/player.gd +++ b/nodes/player/player.gd @@ -105,12 +105,8 @@ func jump_state(_delta): $fsm.set_next_state("climb") func on_enter_climb_state(): - sprite.modulate = Color(1, 0, 0) velocity = Vector2(0, 0) -func on_exit_climb_state(): - sprite.modulate = Color(1, 1, 1) - func climb_state(_delta): if is_on_wall(): var direction = Input.get_axis("player_up", "player_down") @@ -186,9 +182,10 @@ func handle_sprite_orientation(): var should_flip_with_wall_left = (wall_position > player_position) && (velocity.y > 0) var should_flip_with_wall_right = (wall_position < player_position) && (velocity.y < 0) sprite.flip_v = should_flip_with_wall_left || should_flip_with_wall_right + sprite.flip_h = false - elif is_on_ceiling(): + elif is_on_ceiling_only(): if velocity.x != 0: $oriented_container.rotation = PI if (velocity.x > 0) else -PI sprite.flip_h = velocity.x > 0 @@ -199,6 +196,7 @@ func handle_sprite_orientation(): sprite.flip_h = false func on_enter_swim_state(): + sprite.modulate = Color(0, 0, 1) gravity = WORLD_GRAVITY / 2 func swim_state(_delta): @@ -213,6 +211,7 @@ func swim_state(_delta): die() func on_exit_swim_state(): + sprite.modulate = Color(1, 1, 1) gravity = WORLD_GRAVITY sprite.modulate = Color(1,1,1) diff --git a/nodes/player/player.tscn b/nodes/player/player.tscn index d89c776..c59eed0 100644 --- a/nodes/player/player.tscn +++ b/nodes/player/player.tscn @@ -5,7 +5,6 @@ [ext_resource type="Script" path="res://scripts/ia/fsm.gd" id="2_ix1o4"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_w17ly"] -radius = 7.9984 height = 24.0 [node name="player" type="CharacterBody2D"]