I'm trying to figure out how NPCs, AI, "monsters" or even non-static entities with physics would work in a real time multiplayer environment.
In a purely player occupied instance, I know that the environment can be static and unchanging/non-interactive with all players, creating no desync issues and requiring only update positions and velocities from the players.
However, the conceptual problem (for me) comes for implementing monsters/NPCs, since they aren't their own player&client receiving and sending inputs/outputs to the server. They cannot be generated and their physics interacted with on one player's client unless they're in singleplayer, because the interactions could cause conflict in other clients, with the monster/NPC wanting to behave differently from different clients hosting its behavior. A master client is not a good solution, since it could disconnect.
It appears to me all the AI and physics would have to be hosted in cloud code, even for something as simple as a moving object/platform.
For something like WoW behavior NPCs, the same thing:
P1 Joins Session -> Server Countenances/Announces P1 -> P1 Navigates Environment -> Server Detects P1 Enter Enemy Spawn Zone -> Server Spawns Monsters -> ??
This would require a coordinate area to have as 'spawn zone' stored on the server (easy enough), then the spawned unit would have a patrol and aggro radius which would require the announcement of movement. Patrol paths could be setup with a checkpoint system in Unity and then the co-ordinates translated over to make the unit move from one point to another on the server.
The issue is: how would the monster/NPC move or do anything if it's not being calculated by the client, because of the conflicts?
I haven't found any tutorials or references on this, for real time. The real-time tank tutorial involves only players and static objects like walls, not moving NPC objects.
Even just a basic tutorial or reference on how a moving platform would work, would help me understand conceptually how to accomplish this.
I have this question as well.
So far I found
Particulary SetInterval, I think whatever you do would have to revolve around this.
I suppose for GS real-time server, there is only the master client solution is feasible. For the concern in connection lost, we might consider "baton" it from one to another while one lost connection. If you found other proper solution, it would be appreciated if you post you thought