Can't get RPC to call on server-owned vehicle by client

Is it best to have the server or a client own a vehicle? Right now the client owns a driver pawn, not the vehicle itself. So when I try to call a RPC within the vehicle it doesn’t respond to the client. As I understand, it’s best for the server to still own the vehicle. So how do I get the vehicle to respond to input from the client and the vehicle events to still replicate?

This is within the widget for the driver pawn to call an event on the vehicle

This is the beginning of that event within the vehicle that only works on the server because the client is not the owner.

Hello! The approach is correct.

The vehicle is the pawn right? Are you marking the event as reliable?
If the client is the owner of the pawn the RPC should call correctly.

Some debugs you can do:

  • Be sure you are running the game in dedicated or client mode.
  • Be sure you the reference of the vehicle is correctly set.
  • Be sure you are controlling you pawn (Shouldn’t the case because you are getting your pawn from your UI)

I recommend always to check the Unreal Network Compendium.

Actually the pawn the client is controlling is not the vehicle. Their pawn (I called it a passenger pawn) is attached to the vehicle. Other players can posses passenger pawns that are attached to the vehicle as well. The idea was that each player would control a portion of the vehicle. In this case the player would start the movement of the vehicle (projectile movement). They would also modify the velocity. Other players will control weapons, shields, etc. So it made sense to me that the vehicle should remain owned by the server. Does that make sense?

I want to know who owned the vehicle too, or can we find the vehicle owner by iterating its outer? mentioned by that document?

Ok! I get the context now.
For owning something you should set the owner in the spawn.

My recommendation is to use component in your pawn the works as a proxy between the client and the server. After that the server modify the vehicle.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.