I have a multiplayer game where players can walk up to a terminal, solve a puzzle, and open a door.
Who should “own” the terminal actor, thereby allowing its state to be replicated when it’s time for the door to open? Can multiple players own the same actor?
The problem I’m having is, once the puzzle is solved, I’d like to use a rep notify to simply change the puzzle to “solved” and have the door open in response. However, since the terminal and door actors are placed on the map when the game starts, they have no network owner, and therefore any RPC calls I make are discarded.
At what point should network ownership be assigned to one of many potential players who could solve the puzzle?
Create a new client-to-server RPC in PlayerState or PlayerController or Character, and pass the terminal actor as parameter in that function. Upon completion the terminal can call PC->ServerCompleted(Self), and that server function would do Terminal->SetSolved(true).
Alternatively, use an overlap event on server-side to spawn a temporary actor for each player to serve as replication channel. Temporary actor can have bOnlyRelevantToOwner enabled because others don’t need to know about it.
Both approaches have pros and cons.
The first alternative is simpler and doesn’t spawn additional actors, but requires additional function in a core game class.
Second alternative is more self-contained, it can be implemented by mapper without touching core game classes. However you might have to carefully manage those spawned temporary actors! (eg. store them in an array, clean up upon EndOverlap…)