Corona-cation (Day 18)
Success with multiplayer ft. Steam
I spent all of today looking more into how to get internet multiplayer working. The first attempt was the port-forwarding from yesterday. Either I did it wrong or it didn't help. I thought I opened port 7777 but after I did nothing changed and I wasn't able to connect to anyone. It's possible that the other person also needs to have a firewall rule for the same port? But I don't know.
The next thing I tried was the advanced sessions plugin that I originally tried with for the creative jam. This time I went through the setup step-by-step to see if I could get it to work. Very long story short... it (and I cannot stress enough) FINALLY works. I followed along with this tutorial series up until part 7 and over 3 hours later it was all worth it.
There were some hurdles but I am overjoyed now that it works. The initial setup required adding lots of #includes to source files (one of them from the video didn't work though), borrowing from steamworks, and downloading a plugin. Then something I found weird was that you had to create just a blank c++ class to get the plugin code to compile. After all that you finally have the plugin installed correctly. I also had to create a new game instance to handle all the joining/hosting stuff. Most of the rest of the tutorial was making nice looking UI which I didn't follow and instead used what I already had.
After all that was done, I tested and it wouldn't let me host or search for games. At that point I thought I had gone backwards and screwed the game up more. Some time and debugging later I found that the problem was that I was trying to use our custom player controller instead of the default as the input for host and join session nodes. I don't know why it doesn't like it but if I just got the player controller and didn't cast to our one it just worked. After I removed all (or what I thought was all) those cast nodes the hosting worked fine but the searching for sessions didn't.
I thought I had found the culprit in an event dispatcher that I was using when the find sessions node completed. The node had a warning that said "No value will be returned by reference". More attempted debugging later I gave up and looked to google for answers. As it turns out it's a bug with the engine: Warning node generated on compile for component based Event Dispatchers UE-42065. So thanks unreal for irreversibly wasting my time. However, when I found that the dispatcher was not in fact to blame I became even more confused. Turns out the real issue was that I had missed one cast node and when I removed it, the whole thing worked in editor.
I then ran a packaged game on my and my brother's computer to verify, and it worked. I will be cleaning it up and committing it to git tomorrow. As well I will take some screen-shots/videos of online sessions and upload them to this blog.
Comments
Post a Comment