[Resolved] AI Behavior Tree + Multiplayer

Hello everyone i need you help !

I currently dev a online game (Type Arena) I know how to create and how works Behavour Tree but i don’t no how to applicate on multiplayer
There are any tutorials any explain how to replicate all action of enemy to Client & Server same time.
All variables is replicated & the enemy has spawned with server directly.


I would personally approach this by making the server do all of the logic, and then multicasting the montages. Example: make those RPCs in your screenshot server only, then create a “MulticastMontage” RPC which is set to multicast, then have the server call those instead of directly calling montages. In the “MulticastMontage” RPC, have the montage play there, and all the clients should see the montage play. Take this same paradigm and apply it across the board: logic done on the server, visuals are handled with a multicast called from the server.

Like this ? (Edit: I added C2A after random xD)

That looks like it could work. Just ensure that the server is what calls the multicast. Have you tested that code?

Nothing happen on Client… :confused:

What about the server, do things look proper there? Throw some prints in there to see what logic is being run, and where. If you only see prints from the server, it’s only running on the server.

It requires some understanding of replication, and I don’t think most people will be up for writing your code for you or stepping through every bit of it to ensure that you’re doing it properly. The general idea is to run all logic on the server, and replicate visuals (pawn locations, animations, etc.) to the clients to keep things visually in-sync. Step through your code and ensure you’re following this paradigm.

“Nothing happen on Client… :/” is a very, very vague statement as well. What does that mean? Pawns are spawned/visible for clients, but not moving? Not attacking? Pawns aren’t visible for clients but are for the server? Every single step of your code must be setup to support your goal of replication. That means, if a pawn spawns, the server handles that logic and replicates it to clients. If a pawn needs to attack, the server handles the logic and replicates. Etc.

With such a vague statement, it’s hard to help in an effective manner.

-> This enemy is a boss is spawned (On server) when my map is loaded.
-> This Boss is appear on Client/Server.
-> But i doesn’t work any action on client but on server is work.

Server receive 1, 2 & 3 Print
Client receive just 1 not 1&3 …

The client prints 1 and not 2 or 3, or the client prints 2 and not 1 or 3? “Client receive just 1 not 1&3” appears to have a typo and I can’t discern which of the two scenarios you mean. I’m assuming it only prints 1, but I don’t want to theorize based on assumptions.

Sorry client i printed nothing but server printed 1, 2 & 3.

On this screenshot i added print 0 on BP_Boss to see if spawn default controller is worked after cinématic and client/server show 0

Have you tried throwing in a print in the onBeginPlay of BossDW401? I’m curious who acknowledges that the actor has even spawned. I don’t think I’d programmatically set replication after spawning, but rather set the replication details in the class defaults. I’m not convinced that this is where your issue is, but changing replication on the fly can have some interesting, usually unintended side effects.

Nothing change when i delete “Set Replicates” or if i remplace Spawn AIFrom Class To Spawn Actor the ai behavior don’t work on client.
So i tested printed on BossDW401 & client/server show “hello”
I tested directly on BP Boss to check if all code is work i called S2A Server Replicate on to beginPlay he work when i call on beginplay after this i don’t understand why on client he get different animation to server & sometimes the client don’t run animation.

I though AI was already replicated

I delete “Set Replicates” and nothing change on client nothing show on print & on menu debug i have just server debug but not client.

Deleting that isn’t a solution in itself. You also need to ensure that your actor’s components are replicated as necessary. For the sake of troubleshooting, just set the actor to replicate and movement to replicate.

I resolved !!! AND is logic ! the AI Behavour is only work on server so i seek you’re idea

So on to behaviour tree i called all logic selected animations after this i called on my BP_Boss a Multicast to go to play a animation ! And is worked !
i show the picture if helping another people :slight_smile:

Thank you !!! One Mode Only to patient & to try to understand with my bad segfault english :slight_smile:

Hey I’m glad you got it figured out! With solving this problem, you’ll also have gained some awesome long term knowledge on client/server relationships as well. Nice work!