🍻 Mitigates an issue where the player moves freely in the water

main
Ervan Lefevre 2 years ago
parent 57dcd72f36
commit a604c99a42
  1. 9
      nodes/player/player.gd
  2. 1
      nodes/player/player.tscn

@ -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)

@ -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"]

Loading…
Cancel
Save