How can I make the client to control the car I have placed in the map in multiplay mode?

Now there are two car pawns called Sedan and Sedan2, and there are also some NetworkPlayerStarts in the map(Picture 1).


I want to run this project in a server window and a client window, so I selected New Editor Window(PIE) and set the Number of Players 2(Picture 2).
e881bb850a9ce3ea6c2db536db4fe3de87cfaaa8.jpeg
Then I set both of the car pawns as Picture 3 shows,
e0bf3682a33dffb35ec09ac946611e0585e2413d.jpeg
I open the level blueprint and set it as Picture 4 shows.

After all, when I click the Play Button, I found that the server can control one of the car pawns called Sedan and the client can control a new car pawn which appears in the place of NetworkPlayerStart, just as Picture 5 shows.

How can I make the client to control the car called Sedan2 I have placed in the map?

Hey there,

the way you handled it clearly shows that you need to learn about Networking first. You kinda violated all the “rules” :smiley:

Example:

#1: PlayerController(0) and PlayerController(1) is not for Networking (LAN/Internet), but for Splitscreen. Means PlayerController(1) is not even a thing in your Setup.
#2: Same goes for “AutoPossess” set to Player0
#3: BeginPlay of the LevelBlueprint calls on all Players. So you are calling possess on all instances while also always using a non existing PlayerController(1). This is simply not how it works :stuck_out_tongue:

Possessing needs to happen on the Server. Either you set the DefaultPawn to the Sedan and let the GameMode handle that by its own

OR

You set it to NULL and use the “OnPostLogin” function of the GameMode. It passes you the PlayerController of the new Player (including ListenServer).
At that point you can SPAWN a new Sedan and use the passed PlayerController to call POSSESS on it.


If this is all news to you, I would highly recommend you to read my handy compendium: http://www.cedric-neukirchen.net