C++ Issues & multiplayer

I just don’t understand this C++ stuff. I’m trying to design a dedicated server for multiplayer. Yet, I’m running into so many issues. I’ve never had this many issues dealing with blue prints. It seems like nothing works the way it should so I’m having to find all sorts of work arounds. Here’s a few things I’m dealing with. So, I’m following a tutorial to create a dedicated server. The tutorial can be found here. How To Make A Dedicated Server - Unreal Engine 4.25 - YouTube

I download Engine Source Code and set it up. I go create a project. I make it a blueprint project. I create a new C++ class. I save the file on my documents. An ugly error message pops up saying “Exception 0x80131515 File name: …UE4Rules.dll System. NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch.”

For several days I’m nonstop trying to figure the solution to this cuz it appears nobody else using Unreal has had this problem. It appears my computer is blocking the Unreal Engine File. Even when I click unblock it still blocks it. Finally, I discover if I save my project on the C:\ the error message goes away. Something about admin rights I guess. I then go to create a C++ class like the tutorial. But, then it gets hung up. I learn about something called hot reload. I turn off hot reload, and my new C++ class doesn’t get hung up. But, I notice something. The guy on the tutorial, his compiles fine no issues. Yet with mine, a message pops up saying “Class was created successfully, however you’ll must recompile before your changes will appear in the content browser. Failed to generate project files.”

I close my project. I go to my file folder. Right click on my project and click Generate Visual Studio Project Files. A message pops up saying its missing Voxel files (I have the Voxel pro plugin). So, I download Voxel files. Create a Plugins folder and extract my Voxel files there as per the Voxel instructions. I go to open my project and a message pops up saying “modules missing. Would you like to rebuild them?” I click yes. Then an error message pops up saying “Could not be compiled. Try rebuilding from source manually.”

This is the kind of stuff I’m talking about. Anything related to C++ is only sorta working relative to others whose work fine. Like why do I have to save my C++ projects on C drive? Nobody else has this issue. Why is it when I go to create a new C++ file I get error messages. When others create C++ projects they don’t get this. Why is my project demanding I have to install Voxel files just cuz its C++? This never happened with blueprint projects. And why is my project rejecting the Voxel files it wants forcing me to go through Unreal source code. I don’t know what that means?

Its like there is something off with Unreal C++ in my system. I never had any of these issues with blueprints. Everything worked smoothly with them. I’m using Visual Studio 2019 with Unreal 4.24.1 But, I know that’s not the problem. I did multiple downloads of VS 2019, and I triple and quadruple checked making sure I had all the correct developer tools for VS.

I’m at a complete loss. I’m seriously wondering if something might be off internally in my system which is causing all this mess with C++. If not that, I’m wondering if the vendor that refurbished my computer put it on insane security settings. IDK, all I know is this is a real pain in the ■■■!

So yeah if anyone can help, please help me understand what’s going on. Is this normal?

Could not be compiled. Try rebuilding from source manually.

This usually means you have errors in your code that need to be fixed. You’ll need to open visual studio and fix the errors first.

When you use a source build of the engine, you should also keep your project in the same folder as the engine root folder (see the UnrealTournament folder structure on GitHub). Not doing that can sometimes create build problems. You can use Junction Links too, if you want to keep the project on another physical drive. I strongly recommend using an SSD for both engine and project - and as a protip, you should add both folders to the list of Windows Defender exclusions as well.

When you use a source build of the engine, you cannot use plugins from Marketplace unless you have the source code, because your custom engine version has different dll’s and will therefore not match the compiled engine you download from the launcher. The plugins need to be rebuilt for your engine version.

I think the last message I sent went private on accident. I’m new to using this. So, I’ll just copy and paste my reply should others need the info…

I decided to look into what you were advising. I believe the first error I mentioned (exception 0x80131515) may had possibly been occurring due to me putting the UE Source Code on C drive and saving my projects to My documents. From now on, I’ll make it a point to keep my projects in the same folder as my UE Source Code. Also since I’m running windows 10, I went to my windows security and set all my UE projects as well as my UE Source Code to exclusions list. This though seems a bit tedious. Every time I create a new UE project. I’m gonna have to open up Window Security and add the new project to the exclusions list. Would it be possible to create a sub folder in the same folder as my UE Source Code, and add it to the exclusion list. Then any project I create from then on I could save there thus it would automatically get excluded. For example, save my UE Source Code on drive C. Then on the C drive create another folder called UE projects where I save all my UE projects and add it to the exclusions lists. Would that work?

I also looked into what you were talking about concerning plugins. I discovered that the Voxel plugin I was adding to my projects was the free source code. I had to get in touch with the creator, and he gave me links to the pro source code. Once I did that the Voxel errors went away. One thing I noted though is its impossible for me to create a C++ project. When I do this the Voxel errors occur. Yet I can’t add the Voxel files until I have a project created. Its like a chicken egg situation. The only solution I can come up with is first create the project as a blueprint project. Then I can access the project’s files and add the Voxel files. Once that’s done, I can create a new C++ class which forces the project to convert into a C++ project.

I really appreciate the help! You helped clear up a lot of things which were frustrating me. It appears that the problem wasn’t due to an internal computer issue. That’s a major relief. Though your mentioning solid state drives concerns me a little, since my computer doesn’t have SSD. I noticed it took my computer like 7 hours to build the UE source code the first time. I know its supposed to take a long time, but I believe 7 hours is way too long!

Yeah compiling the whole engine can take a very long time. Is there a reason you are using a source build of the engine? You shouldn’t need to work with a source version of the engine usually unless you are working on console platforms or making engine changes.

I have a dedicated drive for my UE-related stuff, and the whole drive is excluded. Note that this is a fully optional step, but it just stops windows defender going through hundreds of thousands of files for no reason, it’s not neccesary but can be useful when working with engine source.

The reason why I’m using a source build of the engine is cuz I’m trying to develop a dedicated server for multiplayer. According to the Unreal documentation on setting up a dedicated server Setting Up Dedicated Servers | Unreal Engine Documentation On the requirements list it says “You must be using a source build of Unreal Engine” I don’t have any plans to work on consoles or making engine changes. My plan right now is just personal computers.

Though many of my issues I posted earlier are cleared up, I am running into another issue. I decided to stop doing the above tutorial because I was running into issues with setting up the short cut to access the server map. I tried 2 different Youtube tutorials on setting up a dedicated server. In both tutorials my short cuts failed even though my syntax was identical to theirs. Every time it said invalid path.

To by pass this issue I decided to start doing the Unreal dedicated server tutorial:…ers/index.html The problem arises at this point in the tutorial. It says…

  1. In the Solution Explorer, unfold the Source folder and locate the [Project].Target.cs file. This is the default build target for your project. There is also a [Project]Editor.Target.cs file for configuring how the Unreal Editor builds for this project. We will create the server build target in this same directory.
  2. Open the Source folder in Windows Explorer. Create a copy of [ProjectName].Target.cs and rename it [ProjectName]Server.Target.cs. Here, the resulting file is called TestProjectServer.Target.cs.
  3. Return to Visual Studio, then click and drag *Server.Target.cs from your Explorer window into the Source folder in the Solution Explorer.
  4. Open [ProjectName]Server.Target.cs and replace its contents with the following target file instructions:

using UnrealBuildTool; using System.Collections.Generic;

public TestProjectServerTarget(TargetInfo Target) : base(Target) //Change this line according to the name of your project
Type = TargetType.Server;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.Add(“TestProject”); //Change this line according to the name of your project

Warning: Be sure to replace all instances of TestProject with the name of your own project.
5. Locate the .uproject file for your project in its base directory, then right-click it and select Generate Visual Studio Project Files. This will regenerate the Visual Studio solution for your game, and it will discover your *Server.Target.cs file.

I replace the old code with the above code in the file TestProjectServer.Target.cs, and then I click generate visual studio files. After this though, I get this error message:

Failed to Generate Files
Running C:/UnrealEngine-4.24.1-release/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project=“C:/TestProject/TestProject.uproject” -game -engine -progress -log=“C:\TestProject/Saved/Logs/UnrealVersionSelector-2020.09.01-20.55.48.log”
Discovering modules, targets and source code for project…
While compiling C:\TestProject\Intermediate\Build\BuildRules\TestProjectModuleRules.dll:
c:\TestProject\Source\TestProjectServer.Target.cs(6,14) : error CS0101: The namespace ‘<global namespace>’ already contains a definition for ‘TestProjectTarget’
ERROR: Unable to compile source files.

I know they say replace line according to the name of your project, but I purposely named my project TestProject to keep things as simple as possible. My code is exactly identical to theirs and yet I’m still getting error messages. It appears VS is getting the original file I copied from TestProject.Target.cs mixed up with the one I renamed TestProjectServer.Target.cs. I even experimented with changing the name of the class TestProjectServerTarget to a different name such as TestProjectServer or TestProject. No dice, the same error message pops up when I go to generate.

Do you have any idea why its refusing my class name? Or if as you suggested, is there an easier way to set up a dedicated server without having to use the source code? So far it feels like a slow trudge dealing with all this source code and C++. I just barely know the basics of C++. I’d gladly purchase an asset on the Unreal store if I could easily bypass all this nonsense.

A couple of points, because I think it’s going to be difficult to give much help here:

  • If you’re relatively new to the engine and/or this is a new project, you shouldn’t be working with a source build because there’s no need. You won’t be making shippable binary builds anytime soon, and you can test servers in-editor without needing to build anything. I would worry about making builds when you have something reasonably developed. Working with source engine is a massively complicated and convoluted process at the best of times, and you can end up wasting infinite amounts of time trying to get it working.

  • There are full example C++ projects available on the launcher, one of which is ShooterGame which has a dedicated server .cs file you can copy from. These are worth studying because as complex projects they’re better than any amount of documentation or forums posts. Most tutorials are out of date every few major engine updates, so the example projects are far better resources IMO.

I strongly recommend using a launcher version of the engine while you develop, and worry about building dedicated servers when you’re more familiar with the engine. You can still test dedicated Server functionality in a launcher version in-editor - you just can’t build a shippable binary. No asset is going to save you the troubles of working with engine source.

In the past I used C++ to make text games, I knew how challenging it can be. So when I started with Unreal, I made a commitment to stick with blueprints. I reasoned this would be a learning phase and I’d just experiment by following different tutorials. After some time, I wanted to make a major multiplayer survival game project. I would post the game online on a free gaming site. I began developing my game working with AI, lighting, sound, NPCs, and recently procedural generation. I wanted my game to foster emergence. To do this I began designing emergent systems whereby everything was interconnecting with each other. The game was rapidly becoming complex. I decided to start looking into multiplayer.

My initial plan had been to create a full game and then add multiplayer functionality to it, but to my horror I discovered I was going about this the wrong way. The Unreal documentation said that I should had been incorporating multiplayer capability into my game from day 1. Similarly I had never packaged my project, I had always assumed that since it worked in the editor it would work fine as an executable. It was at this time I grudgingly abandoned nearly half year’s worth of work. I created a new project and I said we are gonna do this right this time. I’m gonna create a workable project from beginning to finish.

Which brings me to the present. The reason why I’m pushing myself to endure all this torture of engine source and C++ is because I want a completely functional game from beginning to end. Once I have those systems in place working, I can gradually add and test all those game play elements I had to abandon. I want to avoid packaging a 20 gigabyte project and 100s of errors swamping me all at once. I’d rather deal with 1 or 2 errors at a time. Basically, I don’t want to put in another 6 month’s worth of work only to have to take a sledge hammer to my project again.

The main reason why I was creating a dedicated server was for replication practice. I have a second computer. I figured if I could get the multiplayer working on both of them it wouldn’t be too much of a stretch to get them working on friends or strangers computers. Though I am concerned about security issues dealing with strangers. But now you are telling me that I can test all the multiplayer features on my own system, and Unreal has a fully functioning dedicated server project.

So basically you are telling me if all the replication works properly in the Unreal editor server and editor client windows, it should work identical if its ported to other computers and servers? This would be a welcome relief cuz then I could return to focus on my project development instead of fighting with compilers and 7 hour builds.

Yeah Multiplayer isn’t something you can inject at the end of a project, it’s very difficult (and usually quite soul-destroying work) trying to convert a single-player game to multiplayer. Multiplayer makes the development process a minimum of 10 times more difficult in my experience, and you can expect even the most basic ideas to take much longer to implement properly.

So, within reason you can test most basic functionality yourself on the same machine. The engine even has systems for simulating networking issues like latency and packet loss (which you should test with frequently). But yes there is a project called ‘ShooterGame’ on the launcher, which is a dated but complete FPS example project. I seem to find myself directing people to all the time…

Not neccesarily, but it’s good enough when starting on a project. You should still package up and test often - but you don’t need to work with a source engine build to do that, you can just use listen servers or the in-editor dedicated server options when starting out.

Multiplayer is extremely difficult on it’s own until you start to grasp replication and all the pitfalls, but working with source from day one won’t make life any easier.

Time to take another sledge hammer to another project. I’m gonna take your advice and just stick with the launcher version of the engine. If I have issues in the future, would it be okay if I directly message you? I’m basically going solo, and I have little in the way of support.

I appreciate all the help you’ve given me!

I’ll likely be too busy to respond honestly. The best place to get help quickly is the UE4 Discord group. Lot’s of experienced bodies there willing to chip in often, myself included.

Totally disagree!

In my experience Multiplayer makes things about 3.8 times more difficult.
Saying it’s 10x more difficult is just fake news, trying to make it seem more difficult than it is, probably in an attempt to discredit multiplayer programmers everywhere.

Also: Making a player-hosted server first is a Really Good Idea. Once you have a game that is both a) fun and b) networked, and c) works with player hosting, turning it into a dedicated multiplayer server isn’t that hard. Trying to build the dedicated server first, ahead of the other parts, is putting the cart before the horse, though.

Start a new project with the downloaded 4.25.3 engine. Make it a C++ project of some flavor. Turn on “download debugging symbols” in the download options for the engine version. You’ll get quite far staying on that pretty well-developed path!

10x wasn’t meant to be taken literally, but my point is that the complexity of online game development is exponentially higher than local-only.

Even the most simple mechanics, moving an object, shooting another player, using physics vehicles or objects - these often require a lot of additional supporting systems (Prediction/Rewind, Lag Comp, Anti-Cheat to name a few) that aren’t trivial to build and even less trivial to test properly. There are countless additional considerations for online games that aren’t relevant to local games. It shouldn’t be taken lightly.

On average it takes me a few days to 1 week to get familiar with something new in Unreal. Its now been over 1 month and I still haven’t even gotten a dedicated server working. I’ve gone through the routine so many times, I’m starting to memorize it. The problem isn’t as much Unreal as it is Visual Studio and C++. VS just keeps rejecting my server file stonewalling me from being able to build it.

Normally, when I encounter an issue in blueprints I can gradually filter out the solution by online research. VS on the other hand is like this foreign land. I don’t speak its language and I don’t want to. I just want to know the bare minimum to be able to pass over it to get to my destination. Besides, honestly its a waste of my time. I still need to create stats, inventory, resource system, interaction system, AI system, animal system, weather system, main menu, etc, etc. And, that’s just to make a base game.

I knew once they required me to start messing around with the file folders it was gonna suck. In all my years of game design and programming, designing multiplayer has been the worse! I hate it with a passion!