#How to manage interactions?
1 messages · Page 1 of 1 (latest)
Yeah seems pretty sensible
My approach would be this:
InteractibleObject (can be anything)
InteractionArea (custom class that extends Area2D)
Then the player does :
func _on_raycast_area_collided(area: Area2D):
if area is InteractionArea:
area.interact(self)
The area is like :
class_name InteractionArea extends Area2D
signal interaction(source:Node)
func interact(source : Node):
interaction.emit(source)
And then the parent Node of the area can react to the interaction signal, check the type of the source, etc.
This way you avoid relying on groups, which are not type safe, and the system stays very flexible
I see, yeah that seems a bit more streamlined that what i had, i'll try and implement that as soon as i'm home, thank you very much