2 Player Controllable Vehicle in Blueprints

I’m developing a coop game that is on Listen Server and I want to add a vehicle that is possessed by the driver that has steering wheel controls and a passenger that has throttle and brake controls.

I currently have the driver that has all the controls assigned on him (He possesses the vehicle) and my passenger can enter the vehicle but can’t control the throttle and brake.

I have a IMC_Steering Wheel and IMC_Throttle_and_Break in 2 different Input Mapping Contexts.

How would I be able my passenger to control the throttle and brake WITHOUT possessing the vehicle?

Passenger has his own player controller (PC), so you could manage it through it →
PC receives input locally, PC calls server function on itself (like ServerBrake) and then server calls Brake on a vehicle that this PC uses (you should store vehicle as a separate variable, since passenger is not possessing that vehicle).

So I changed it up a bit and added this to my code. I have a collision box in the passenger seat and when I press “E” key, I can sit on the seat and I trigger an “Add Mapping Context” function that switches my default IMC to the Vehicle’s IMC.

Basically, whenever I get into the vehicle and press “W”, it appears that the Input Action event below there is working. I get “1.0” Float value when pressing it and when I stop pressing it I get “0.0”.

The problem is the car doesn’t move anywhere, I can’t control it still.

In this setup you will end up having replication problems with the passenger.

  • Player 1 possess the vehicle, which means that it is an Autonomous Proxy on Client 1
  • Player 2 needs to control the vehicle’s throttle so you would need to command a Simulated Proxy on Client 2 which is impossible to do directly. (It is also impossible to possess the vehicle from two different controllers.)

The way I see it (keep in mind I’ve never tried something like this) is as follows:

  1. Player 1 possess the vehicle as you are currently doing it.
  2. Player 2 sends RPCs either directly from the controller or some invisible pawn.
    (Ignore for now that player 2 doesn’t move with the vehicle)
  3. Make the server event update the vehicle’s throttle.

This will most likely produce errors on Client 1 as it assumes that Player 1 is the sole controller of the possessed pawn, in which case just make Player 1 posses another invisible pawn like Player 2 does. It might be necessary to posses the vehicle with an AI controller to work. In this case, the AI is actually possesses the vehicle but the players posses a “remote control pawn” that would give it commands.

This is a really ad hoc solution - it might work but if you want it done for production, you will really have to modify core systems like replication, network predictions and movement controllers.

For additional information see: Actor Role and Remote Role in Unreal Engine | Unreal Engine 5.7 Documentation | Epic Developer Community

So I’ve tried doing something different than the one before. The code below is inside the “BP_Player1” (which is a copy of BP_ThirdPersonCharacter). Basically I tried to make a “Blueprint Interface” as you can see and I tried carrying the Action Value Float data between classes with it. According to the codes below, I managed to get the Action value working. Like, whenever I press “W” key, it prints the value as “1.0” and whenever I lift, it goes back to “0.0”. The thing that I’m struggling is I can’t trigger the “Set Throttle Input” function. Any ideas you have on this matter would be very useful. Thanks!

This one is inside the BP_VehiclePawnBase. Since my vehicle’s parent class is this one, I tried using it.