Godot Version
4.6
Question
You see my scene tree every Animated sprite has the same two animations: “Idle” and “Hovered”, i am trying to make this single script control interaction since im making a horror cooking game and will reuse a lot of mechanics.
I ran into this issue which i believe is simple but i kinda can’t figure it out can anyone help
If you share code, please wrap it inside three backticks or replace the code in the next block:
extends Area2D
class_name Interactable
@onready var Sprite = AnimatedSprite2D
@export var selected: bool = false
func _ready() -> void:
` Sprite.animation = "Idle"
func _on_input_event(_viewport, _event, _shape_idx) -> void:
if !Input.is_action_pressed("Interact"):
selected = false
Sprite.animation = "Idle"
else:
selected = true
Sprite.animation = "Hovered"
func _physics_process(delta: float) -> void:
if selected == true and is_in_group("Interactable"):
global_position = lerp(global_position, get_global_mouse_position(), 25 * delta)
