- Edited
[EDIT]: ANSWER
The shader was applied to all instances. So i had to make it unique by checking the 'Local to scene' option in the Material panel:
resource_local_to_scene
If true, the resource will be made unique in each instance of its local scene. It can thus be modified in a scene instance without impacting other instances of that same scene.
Context
I'm trying to highlight (with a shader) a NPC on mouse_entered
Objective
I want to automatically connect 'mouse_entered/exited' from parent class to each child.
Problem
Here i want only 1 'Ruth' child to be highlighted at the time, on 'mouse_entered'
Tree
My obviously not working code
# Parent class
class_name NPC extends StaticBody2D
func _ready():
var _highlight_entered = connect("mouse_entered", self, "npc_mouse_entered")
pass
func npc_mouse_entered():
$AnimatedSprite.material.set_shader_param("outline_width",0.3)
func npc_mouse_exited():
$AnimatedSprite.material.set_shader_param("outline_width",0.0)
# Child
extends NPC
How can i achieve this ?