How do you make it so that, if you walk up to the stove it displays the stoves animation in 2d?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gamer53

extends KinematicBody2D

onready var _animated_sprite = $Sprite
var speed = 200
var velocity = Vector2.ZERO

func _physics_process(delta):
velocity = Vector2()
if Input.is_action_pressed(“right”):
_animated_sprite.play(“Idle_right”)
velocity.x += 1
if Input.is_action_pressed(“left”):
_animated_sprite.play(“Idle_left”)
velocity.x -= 1
if Input.is_action_pressed(“down”):
_animated_sprite.play(“Idle”)
velocity.y += 1
if Input.is_action_pressed(“up”):
_animated_sprite.play(“Idle_top”)
velocity.y -= 1

func _process(delta):
velocity = velocity.normalized() * speed
velocity = move_and_slide(velocity)

func _on_Stove_tree_entered():
$Label.text = (“Player”)

func _on_Stove_tree_exiting():
$Label.text = (“”)

:bust_in_silhouette: Reply From: exuin

You need to place an Area2D on the stove so it can detect the player. Add a collision shape to the area. Connect the correct signal for detecting the player to the script and play the animation.