Setup for multiplayer radio controlled car

Hi All,

I am doing something very similar to where the player is represented by his own Pawn and Player controller.
But a lot of the game play is about controlling this remote controlled vehicle, like a car.

The game is listenServer-Remote p1-vs-p2 multiplayer.

So when I issue control orders to the car, like ‘Jump’, the Player Pawn captures the input button press and then executes that on/from the Car as a Run-On-Server Custom Event, to get replicated back to itself.

The problem seems to be that because the player does not ‘Own’ the Car, the RPC will not execute.
I tried to add the main Playercontroller to the Car’s ‘Owner’ slot on spawn but that seems to completely flip it out for some reason.

Am I designing this flow in the wrong way?
Is there a more correct way of doing this?

Thank you

Well the idea is correct. You normally need to assign the PlayerController of the Player that should be able to call RunOnServer RPCs to the actor.
This needs to happen when the Actor is spawned.

May i ask why you don’t posses your the cars? If i’m not mistaken, the Vehicle Class is a Child of the Pawn class, so you should be able to simply possess it.
That will make sure the Client owns the Actor and you can call RunOnServer RPCs.

Otherwise, make sure you use the correct PlayerController for the car. You need to take the Server Version of the Clients PlayerController.
Not PlayerController 0 (that’s the listen ones Controller), but the PlayerController of the person who wants to control the car.

Hi thanks for the reply eXi,

I think I have got it to work now. I changed my spawn method to happen in the GameMode’s ‘OnPostLogin’ which has made things easier for me in getting the right PlayerControllers, as I currently find that quite confusing. I’m sure I have to change this later but it works well for now.

For the input RPC execution it seems to work when I double up in the ‘Car’ with both a RCP function and an extra standard input(same as the Player Avatar uses) that also runs the RCP function directly.

Here’s some grabs from a new test scene.


Player Avatar BP:

Car BP:

I’ll also try out your extra possess idea, although can a PC have possession of two Pawns at the same time?


No it can’t. There are workarounds for this, but in general you can only possess one pawn at a time.