I’m trying to set up a simple multiplayer where one player is in VR and the other is not. Basically, I just want to spawn a different character for each player. I was trying to spawn different pawns depending on ‘is server’ bool (if host - take this pawn, if client - take this pawn).
I’m stuck and I can’t figure out how to check this bool. I followed this tutorial:
Where exactly this feature is solved. However, I can’t find where the variable ‘is host?’ is assigned.
I don’t know if it can help you but maybe you just have to tell the Host to take this pawn and the “joiner” client take that pawn ?
Or in your player controller (I hope it’s the same for both…) set On Begin play, a branch with a bool call : AmIHost? if true set spawn pawn to the one you want and if it’s false spawn the pawn you want too
Ok I did it inside PlayerController (build in ‘is Server’ bool), because I think that after I host a game and Open Level, or Join session all variables are back to default (it didn’t work).
This is almost working xd Should I check Run Dedicated Server in the Editor? I got all spawns doubled so twice true (server) and twice fales (client). Two characters are spawned only after hosting a room, without a client yet.
The second player doesn’t spawn properly - no pawn, and camera is like on a default 0,0,0 position. I think it doesn’t possess properly.
Those are however a bit hard to explain issues so I don’t think you will be able to help me with them
ho… I understand. Sorry I didn’t remember this officiel multiplayer tutorial -_-
When I talk to you about the host and the player is cause I use another multiplayer project now, so I can make a room where players can join… So you can tell wich one is the host and wich one is the clients.
But with your multiplayer project you “simulate” multiplayer game.
I think you should take another way…
Make the host launch the game and make a Level event :
On this level blueprint, cast to player controller to make a widget
And choose if you are the pawn 1 or pawn 2 here
Then the second player make the same thing… He join you and choose the second pawn once is in the game with the same widget event
You can make the default pawn be a “do nothing” pawn (or spectator.) Then the server can decide who gets what pawn class, and update a class property in the playerstate.
Then the playerstate will respond to a change of the class property by unpossessing/deleting the currently controlled pawn, and spawing/possessing a new pawn based on that class value.
Yes jwatte this is probably how this should be set up ^^. Thanks Zoruk for your tips too, I’ll try both solutions.
How about this Begin play? I have ONLY BeginPlay -> Print String in my PlayerController. I play in Selected Viewport with number of players: 2. No dedicated server. Clean GameMode and Level Blueprint. Default IntPawn. I receive ‘Hello’ from Server twice and once from Client. Why twice from Server?