Is a client aware of existing AI Controller?

Hey there,

lately I’ve been messing around with RTS Controls and set up a system, that works very well as single player, but causes a lot of headache once I try to connect a client to the server. As basic, my player controller simply sends commands to an AI Controller which then moves the actor (Character) through the level. Once I connet as client however, it appears as the 2nd Actor spawned (for player 2) does not get an AI Controller spawned/assigned, as its AI Controller comes up as “none” for an unknown reason.

I’ve tried several ways to spawn actors controlled by the AI Controller, though the actor spawns without any issues, the 2nd Actor spawned does not get an AI Controller (of the same class).

  • 1st Attempt: Have each player
    controller spawn their own Actor,
    send reference of pawn to AI
    controller and let it possess the
    pawn

  • 2nd Attempt: Have each player
    controller spawn their own
    Actor+Spawn Default Controller (which
    in this case was by that time an AI
    Controller)
    –>> Made plenty of adjustments to the networking part to no avail,
    replicated basically every bit of
    code

  • 3rd Attempt: Have the Server Spawn
    all Actors via sequence and get the
    Pawns & Controllers as variables
    (Pawn_0/Pawn_1 &
    Controller_0/Controller_1)

  • 4th Attempt: as 3 - but on the Client
    I checked Controller_0, which is used
    by the server “player”, with some
    DEBUG string prints, which also came
    up as NONE - although I was clearly
    ably to use my movement command and
    the server was aware of Controller_0

  • 5th Attempt: I checked on Server, to
    see if I am aware of both Controllers
    (_0 &_1) and the server is, the
    client however still has no clue
    about them :confused:

How come? Are AI Controllers only possible/visible for Servers? Replication of the AI Controller Class is active and set as Always relevant…

Any clues why I’m unable to call the AI Controller_1 on Client?

By design, AI controller only exist in server / listen server, the only controller you have in client is your own PlayerController. This to prevent case like any client can hack and control any AI as they want.

Ah true, makes total sense. So how would I go about, assigning AI Controllers to the individual player requests to the server. I.e. - Player_1 (client) requests it’s pawn to be moved to a new location. Then Server Player Controller decides which AI controller to use, based on which player has requested this event.

How would I call a player ‘ID’ on the server and how much would this possible impact the performance :confused: As I’m not out to build a regular RTS but more of a MOBA I assume I could revert back to using player controller logic for movement and just move the camera actor (locally) based on mouse position, but I’ve called in love with the behavior trees and using some of their logic for player movement, rather then making all the condition checks manually.

Cheers,

Supposed this as a Moba like Dota or LOL, the way I apporach this is:

In PlayerController i will make 1 replicated Pawn variable let’s call MainPawn. When PlayerController start, suppose he already choose all the setting like character name, skin,… he will send this setting to server and request to create the Pawn with this setting. Server then will spawn a Pawn with all that setting, assign a AIController, then assign new Pawn to the MainPawn . Since it replicated, in client you will know what pawn you controlled on server.

Any command just make a client-server command from your client PlayerController, then in server can send direct to MainPawn to execute, like move, attack,…

And on the client side, you can take MainPawn, check anything you want like health, mana, skill,… if you replicate all that variables on the MainPawn.

Yupp, I got it now - used this: Does UE4 have client-side prediction built in? - Multiplayer & Networking - Epic Developer Community Forums as an exmaple and it works brilliant - animation is being replicated properly, all actors are moving nicely and I’m still able to focus view on my God actor wich just hosts a camera and the camera movement logic.

Thanks a lot for your advice anyways, as it would have gotten me there as well, if I wouldn’t already have found the other example :slight_smile: