Download

Networking Trouble! Spawn Actor/Pawn from client input

Hello. I’m trying to wrap my head around Blueprint networking and its causing a huge delay in the overall progress of my project. My problem is below:

I want to spawn a player Pawn when the user presses the spacebar, I have the actual function of spawning the pawn on a custom GameState blueprint that then returns the spawned pawn. The server player (listen server in test mode) can do this without issue, however the client fails to spawn. The GameState receives the input, Executes the node, but throws an error.

Maybe I’m approaching this in the completely wrong way, however I tried spawning the players in the GameMode, but then learned that the clients couldn’t even see the GameMode.

Pictures of Blueprint setup:

and the error

A Client can’t send input to the Server on GameState since it is the server that owns GameState. You need to use something that the client owns to make the RunOnServer RPC on. This could be the PlayerController or Pawn/Character or anything else that player owns.

GameMode and GameState goes hand in hand but have slightly different purposes.

GameMode only exist on the server so the clients can’t read it at all. The server might want to reveal/share some information in the GameMode though so the clients can look it up, this is where GameState comes into play.

The PlayerController is where players can send input to the server

For convenience any Pawn or Character the client possess(owns) can also send input to the server.

Thank you.

I’m still trying to wrap my head around replication and the nature of trying to have everything run on the server instead of on the player-owned objects. Is it necessary to offload as much gameplay script to the GameState as possible, or can a hefty amount still run on player-owned actors without causing issues?

I had originally designed the game without thinking much of the networking side of things, and now I’m thinking I’ll need to move a lot of what is happening in the pawn’s BP to somewhere that the server has authority over, or am I completely misunderstanding?