How to handle NPCs #382
-
Is there a suggested strategy for handling non-player characters controlled by the server? Should they have an |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You've perfectly described the two strategies I'm aware of 😄 I've personally used the latter, where I've moved the NPC simulation to the tick loop on the server, so state is completely owned and simulated by the host, and then synchronized via StateSynchronizer. That was the original motivation for adding that node. If for whatever reason you want to make NPC simulation part of rollback ( e.g. it needs to interact with something that needs to be in rollback ), you can treat it as a player avatar controlled by the server as you've described. In this case, you could even experiment with input prediction, so NPCs don't always have to wait for the server before updating. In my opinion, neither is preferred over the other, you need to pick the right tool for the situation. I tend to go with StateSynchronizer if I can, as it's conceptually easier. |
Beta Was this translation helpful? Give feedback.
You've perfectly described the two strategies I'm aware of 😄
I've personally used the latter, where I've moved the NPC simulation to the tick loop on the server, so state is completely owned and simulated by the host, and then synchronized via StateSynchronizer. That was the original motivation for adding that node.
If for whatever reason you want to make NPC simulation part of rollback ( e.g. it needs to interact with something that needs to be in rollback ), you can treat it as a player avatar controlled by the server as you've described. In this case, you could even experiment with input prediction, so NPCs don't always have to wait for the server before updating.
In my opinion, neithe…