Hi again. I have been working on making a multiplayer game. I first followed the Unreal Multiplayer example and my game worked fine. So I had a map named “dev_scene” and if I make two clients in the Game Preview they both spawn separately and using Server RPC I was able to replicate the crouching, running animation etc and movement was automatically replicated by CharacterController.
So far so good
Then I found the excellent tutorials on Youtube (Unreal Engine C++ Steam Server: Part 1: "Project Setup" - YouTube), he has shown me how to add the OnlineSubsystem to the build.cs file. And my “defaultEngine.ini” now looks like this:
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Game/Scenes/MainMenu.MainMenu
EditorStartupMap=/Game/Scenes/MainMenu.MainMenu
GlobalDefaultGameMode=/Game/Blueprints/BP_mMenu_GameModeBase.BP_mMenu_GameModeBase_C
GameInstanceClass=/Script/OnlineShooter.OnShooter_GameInstance
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum
[/Script/Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/OnlineShooter")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/OnlineShooter")
+ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="OnlineShooterGameModeBase")
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
[OnlineSubsystem]
DefaultPlatformService=NULL
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
GameServerQueryPort=27015
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
The functions he uses seem to do what I need. And later in the tutorial series indeed he apparently uses Steam “Space Wars” to test online and in theory eventually launch a game on Steam.
But after I made the Main Menu like in his tutorial, I try Create Server and it loads in all seems ok. But then I try to Join with another and then I suffer varying problems. The problems vary depending if I choose “Play Standalone; Listen Server or Client” in the Preview button.
For example if I click Play as Listen Server, and open 2 previews. I click Start Server in window A and window B has the player spawn in there. And if I move the mouse in Window B suddenly in jumps back to Window A.
Again, the logic worked fine in the main gameplay map. But the Menu with the start server button is not testing well. I’m unsure if the problem is caused by the way I test it.
The full project is on my Github:
If it would help I can post all the code here as well as images of the blueprints. Let me know if you want me to do that. Many thanks for any help.
Also note: I have port-forwarded both protocol for 7777 and 27015