I want to implement a system where a player can interact with various objects in the word (NPC, Chests, Crafting Stations). For that I need a system that allows me to toggle the interaction between a “free for all” mode (aka everyone interacting with the object sees the same) and a “unique” mode (aka everyone interacting with the object only sees the stuff intended for him).
I thought of two ways to implement this, but I’m not sure which would be the better (read: more maintainable) approach.
- When a player is interacting with the world object I’d spawn another invisible actor which handles the interaction. If we are in “free for all” mode only one actor would be spawned and every player would interact with that single object. In “unique” mode every time a new player interacts with the object a new actor would be spawned that handles the player interaction.
- The world object would handle the logic itself, but I’d change the interaction logic based on a player identifier (which I have available since I need it in other parts of the game).
For method 1) it seems easier to implement on first glance, but I’m a bit concerned when I have to spawn many actors. Yes I know simple actors are cheap, but I’d rather keep them low from the beginning.