Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | David_sun |
Hello
I’m trying to get a “player” to open a chest when he presses a key, but only when the player is in a specific area, but it doesn’t work.
Any ideas?
Thank you.
extends Area2D
func _on_chestarea_body_entered(body):
if “player” in body.name:
if Input.is_action_pressed(“ui_focus_next”):
$AnimatedSprite.play(“open”)
func _on_chestarea_body_exited(body):
if “player” in body.name:
if Input.is_action_pressed(“ui_focus_next”):
$AnimatedSprite.play(“close”)