Download

How to spawn actor which is selected in Lobby Map

I’m making a network game, and in my game there is a lobby map and a game map. Players select their characters in the lobby and then their characters spawn in the game.

The problem I’m facing is that I can’t pass the character parameters in lobby to the game map. I’m not using a seamless travel since the gamemode is changed and it is the first time the map is loaded. So the clients disconnect and reconnect to the server. How could I MATCH characters and players?

What I did is record a playername in playerstate, and save it in local computer. When the map changes, the new playerstate loads the name and replicates it. Then Server gameinstance matches the character and the name.

Yet, it is not a good idea because both replication and matching have lag depend on the net, and if the server matches before the replication, there would be errors.

Are there any better solutions?

You can pass arguments and variables if you use the OpenLevel function:

https://docs.unrealengine.com/latest/INT/BlueprintAPI/Game/OpenLevel/index.html

I think I have to edit C++ anyway… I’m using servertravel since I want clients travel to the new map together. I’ve found some posts say I could send arguments like URL. But where should I phrase the function and how could I receive arguments in my new gamemode? What cpp should I edit? THANKS!!

You don’t need C++ for this. ServerTravel can have arguments by simply using “ServerTravel MAPNAME?Argument1=Value1?Argument2=Value2”.

The GameMode has a String Variable called “OptionString” or “OptionsString”. It has the options you passed. You can use “Parse Option” and enter “Argument1” to receive “Value1”.

But after explaining all of this: This won’t solve your issue :stuck_out_tongue:

You can’t match Players without a Subsystem. If you don’t have Steam or any other Subsystem that provides you with a Unique ID per Player, you can’t match them in the new level.
The PlayerID of the PlayerState will change in the new Level.

The only way you can do this is to let the Players save their selection in the GameInstance or in an SaveGame and letting the Server ask the Players after the map has changed.

I’m still been sticking on these problem. I save the data in a file and load when new map is loaded. Yet due to delays, it also always miss match characters…

While I’m making a LAN game because I can’t connect to Steam… I’ve set subsystem as Doc says. But it doesn’t work. I also downloaded the lasted Steam SDK and put them into thirdparty folder, yet the name of the folder was Steamv132 which was a old version. I don’t know what’s wrong… If I can use Steam, I could try Unique ID as eXi says.

Package Log:
LogModuleManager:Warning: No filename provided for module OnlineSubsystemSteam
Unable to load module ‘OnlineSubsystemSteam’ because the file ‘C:/Program Files (x86)/Epic Games/4.13/Engine/Binaries/Win64/’ was not found.

无标题1.png

DefaultEngine.ini:
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName=“GameNetDriver”,DriverClassName=“OnlineSubsystemSteam.SteamNetDriver”,DriverClassNameFallback=“OnlineSubsystemUtils.IpNetDriver”)

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName=“OnlineSubsystemSteam.SteamNetConnection”

Net

I don’t know what’s wrong with my online subsystem settings.

What Delays? You don’t set the Character to be spawned when the Game starts (Set the DefaultPawn in the GameMode to none).
In the GameMode, you use the “OnPostLogin” function, which gets called when someone joins + passes you their PlayerController Ref, and there
you can call a ClientRPC on the PlayerController to get the SaveGameData and then call a ServerRPC, also on the PlayerController, inside of the
ClientRPC, to tell the Server what Character he should spawn. In the ServerRPC you spawn and possess the Character.