Godot Version
4.5
Question
with the current code i came up with,the animations i came up with overlap into each other for some reason instead of one at a time and the right one per area:
If you share code, please wrap it inside three backticks or replace the code in the next block:
extends CharacterBody2D
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D
var state : String = "(floor)"
var entered_walls : bool = false
func _physics_process(delta: float) -> void:
if _set_state() == true:
update_animation()
func _set_state() -> bool:
var new_state : String = "(walls)" if entered_walls == true else "(floor)"
if state == new_state:
return false
state = new_state
return true
func update_animation() -> void:
animated_sprite_2d.play("dancing_souls" + state)
func _on_spritechange_area_entered(area: Area2D) -> void:
entered_walls = true
func _on_spritechange_area_exited(area: Area2D) -> void:
entered_walls = false