- Home /
Best way to accurately network AI movement?
Let me give you some context.
I'm using PhotonNetworking and Unity's built in NavMesh with Agents.
I'm working on a "zombie wave shootem' up". The number of AI agents will go up depending on the number of players and the current wave count. (WaveCount Number of Players 0.22f). So as you can imagine, Over time there will be many agents at any given time.
My first line of attack: Put a PhotonView on each Zombie Prefab. Which means upwards of 100 PhotonViews in the later game. This, according to Unity and Photon forums, is NOT feasible.
My second attempt: I created one "AI_MovementManager" GameObject and script. The script ONLY runs on the masterClient. The master client sends updates periodically to each player regarding each Zombie's position and rotation. The clients then apply that data to the corresponding zombies.
Both of these methods work. However, The first method had great results but was too expensive of the network. The second method is MUCH cheaper due to sending less messages over the network, but it is at a cost of smoothness/accuracy.
I understand networking is mostly Smoke and Mirrors, but players should need an insane internet connection to play a simple party game OR have to put up with (obviously) laggy AI.
If you have an insight or advice for me or anyone else who views this topic, that would be immensely appreciated!
Thank you!
It may be possible to go with a modified version of the second method you mentioned. Have a single object with the PhotonView, give each zombie a PhotonTransformView and whatever else needed, and add it to the ObservedList, then network over the array of zombies current positions periodically - you may not 100% need exact accuracy to their position to be updated in real-time, only their events (when/where they spawned, when/where they died, when/where they attacked, etc)
Because of this, you can get away with keeping the number of network calls down as much as possible, because as explained to me a while ago with networking weapons being fired, "Its not important that EVERY player sees Player 1 fire his gun and muzzle flash exactly as it happens and what Player 1 is seeing, to everyone else - but more important that every player DOES see the flash, it could be a half a second delayed, or even a full second delayed, and out of sync with what Player 1 is actually seeing, as long as everyone DOES see it, when they see it in perfect ti$$anonymous$$g, doesnt matter, but their position does" - which goes onto your "smoke and mirrors" understanding.
Your answer
Follow this Question
Related Questions
Using lerp to smooth network movement causes rubber banding 1 Answer
Only do something if it has the same tag as the player 2 Answers
Photon - Hide/Show Object 1 Answer
Updating multiplayer map on joining 1 Answer
Photon timer issue 2 Answers