Files
CultManor/game/characters/player/state_machine/idle_state.gd
T

24 lines
463 B
GDScript

extends PlayerState
const ANIMATION_IDLE = "idle"
const LOOK_AROUND_CHANCE = 25
@export var look_around_state: PlayerState
func enter() -> void:
player.sprite.animation_looped.connect(_on_animation_looped)
player.sprite.play(ANIMATION_IDLE)
func exit() -> void:
player.sprite.animation_looped.disconnect(_on_animation_looped)
func _on_animation_looped() -> void:
if randi_range(1, 100) <= LOOK_AROUND_CHANCE:
switch_state.emit(look_around_state)