Hi,
Sorry if this is the wrong section, and sorry if there are duplicates of this question out there but I couldn’t find any answers.
So I am making a multiplayer game (on a blueprint project) and I have a lobby system that works as it should. Someone hosts a session (and opens a lobby map in ?listen), someone else looks for sessions and joins it. I have a ready system and only the host can start the game.
However, I have not been succesful using the ServerTravel command. When the host presses start I made it so that it execute this command “ServerTravel TestMap”, TestMap being the map I want to travel to. But nothing happens when I the function gets executed. And if I type that command in the command line it crashes the game.
This happens both in editor (which from what I gathered is a bug from 4.17) and when I run the games on separate processes (duplicate project folder, right click → Launch Game). I only tried it using LAN sessions.
Could it be because I’m using 2 different game modes (one for lobby map, and one for the game itself) ?
And/or something related to SeamlessTravel (which is disabled)?
The problem was that I am using two different game modes, and the ServerTravel function needs to know that. I don’t think it is possible to do it directly via blueprint.
Did you need to recreate your whole project in c++ or did you convert it somehow? Can you convert only one blueprint to c++? Do you think it would be doable just making the solution in the other thread as a function library but making it static and callable from blueprints?
Sorry for all the questions but I too have a blueprint project where I have the exact same problem and I’m not skilled in c++ so if there is a solution with as little c++ as possible I think it would be best for my project.
Hey,
That’s what the other solution will make you do. It basically consist of making a C++ function callable in blueprints. Not too sure what you mean by static tho?
No you can’t convert only one blueprint, but converting your project to c++ won’t get rid of your blueprints and you can still work exactly as you do in a blueprint project. To convert I cant really remember exactly what I did, I googled it and found a guide on how to do it.
Yeah keeping a blueprint project can be better: with a C++ project you’ll need Visual studio on every computer you want to work on, and it will take more time to open. But i’m still working on this project now and it is worth it.
Ok, cool. I tried that other solution once but since I didn’t know what I was doing I ended up crashing my project and it wouldn’t boot again so this time I will do some more research
Is there any chance I could take a look at your c++ code for that function to see it implemented in a working environment? (screenshots of the code for the function, what needs to be added in the beginning of the class, how it looks when called from blueprint)
Also, do you know if it must be a gamemode based c++ class that contains the function? Since I already have my LobbyGameMode setup it would be awsome if the function could be contained in a function library based c++ class.
Anyways, sorry for the million questions, it’s just that I can feel the solution right in front of me
Also, thanks a million for the answer. This has made me determined to solve this issue.
New C++ class, choose Game Mode Base as the parent class.
Copy this in the .cpp, make sure that you get the name right at line 5. It should be the name of the newly created gamemode class with a A attached to it.
That’s basically how I got it working. Since I my Gamemodes blueprints were based off Gamemode base and that I hadn’t changed that class (in C++) reparenting didn’t cause any issue. As for making it in a function library based class, I’m not too sure …
Hey man!
Thank you so much, this got it working in my test environment. Something wierd still happens in my actual project but I do think I’ve gotten one step closer.
A few questions just to see if I’ve understood if you have the time:
By choosing Gamemode as the base for the C++ file we inherit everything from UE4s Gamemode class correct? We simply then add our function, so our own C++ Gamemode class is the same as UE4s + our own function?
By reparenting our BP_GM we are making sure that our BP_GM inherits everything from our C++ Gamemode which in turn inherits everything from UE4s Gamemode?
Could we have accomplished the same result by doing the C++ class first, then making a BP_GM based on the C++ Gamemode. Would it be the same as reparenting our existing BP_GM?
Anyways, thanks alot! Will report back here if/when I find out what the problem in my actual project is.
Ok so I fixed the issue I ran into at this point. It was partly a typo in the .cpp but also it seems that when seamless travel is used it will not call OnPostLogin which is where alot of the stuff in the new GM was built. Using non-seamless travel solved this… HOWEVER this makes the client disconnect without reconnecting when using Steam. Closer but still not quite there
Are you using Steam or any type of online subsystem?
No problem!
Oh really? No we haven’t been using steam yet, only through LAN sessions. There might be a “Connect to online service” node that reconnects to steam? I’ll probably be starting testing with steam next month I’ll update this post if I run into any issue
Alright, hope it works out well. My next place to find a solution seems to be in the AGameMode, HandleStartingNewPlayer. Alot of people are saying this is called after seamless servertravel and might be used “instead” of OnPostLogin. Since I’m a beginner c++ programmer I have not been able to make it work just yet.
Will let you know if I get it working and how