A developer needs to create a generic 'Interact' system. The player can interact with many different types of objects (doors, switches, chests), which are all separate Blueprint classes. What is the most flexible and decoupled method to implement an 'OnInteract' message that can be sent to any of these objects without requiring the player Blueprint to know each object's specific class?
-
A
Create a 'Cast To' node for every possible interactable object type and connect them in a sequence.
-
B
Use a Blueprint Interface containing an 'OnInteract' function and have each interactable object implement it.
-
C
Use an Event Dispatcher in the player character and have every interactable object in the level bind to it on BeginPlay.
-
D
Give all interactable objects a specific tag and use the 'Get All Actors with Tag' node to find and call a function on them.