Multiplayer Behavior Tree Support For NetCode

With NetCode for GameObjects you'll want to run your behavior tree on the server and then sync the results to all of the clients. This means that the actual behavior tree is not synchronized, rather the resulting location/instantiation/etc is. This will give the best results without adding any extra overhead.
 
@Justin I'm not 100% sure that will work well. The tree itself is being used to govern the actions of a turn based board game. If the tree isn't synchronized then the product itself may not be viable.

Here is the tree

Screenshot 2023-02-17 at 2.44.01 PM.png

Here are the variables
Screenshot 2023-02-17 at 2.45.08 PM.png

The Tree itself would have to have the same exact state on all the clients for the flow make sense... Otherwise it might be easier to get rid of the tree and handle everything as a singleton network behavior.
 

Attachments

  • Screenshot 2023-02-17 at 2.45.02 PM.png
    Screenshot 2023-02-17 at 2.45.02 PM.png
    16.6 KB · Views: 4
In that situation you should have the tree running on the server and the results should synchronize to all of the clients. I'm assuming when the card is drawn the game changes state so it shows the drawn card. Instead of the same tree running on each client what you would do is instead just have an RPC call all of the clients to show the card. This way there is only a single behavior tree governing all of the actions. If a player input changes the state of the behavior tree you would send a single RPC to call the function that causes the tree to change state.

In the end this is a lot more efficient as you are not sending the variable values back and forth which may only cause the tree to change state but no visible results on the client.
 
Top