so, ive been using unreal the past few months and im considering a switch to unity… i like the way scripts are more modular and organized, even though i could do the same in UE4, it seems better organized on unity… there seems to be more free assets, tutorials, and a better business model while graphics comparing two games between the two engines in the same genre done equally as well seem to provide equal results and i think with unitys new open rendering available in the current beta that unity3d will be able to do anything unreal can
some questions though… i understand both unreals blueprints and C# used in unity are roughly 1/10th the speed of C++ scripts, and that C++ scripts are always going to be faster, but realistically how noticeable is this going to be and what sort of games would have a noticeable effect using C++?.. and with unity seemingly more adept at breaking up C# scripts into individual, somewhat modular functions, how much easier would it be to rewrite a C# script (say for a simple stamina drain or regen system) to a C++ script in unity than rewriting whole commented sections or functions of UE4 blueprints into C++?
Not all C# is compiled equally some C# project targets in Unity get compiled to native code, some get assembled to .Net code which is then compiled on the target hardware.
Also it varies depending on code and compilation technique from C# being faster to it being about 2-3x as slow.
There is also the new Job System (in Beta) that facilitates making multi-threaded code and once the Burst Compiler/Assembler is brought online it will convert C# code to native ‘hand coded assembly’ optimised for the target platform.
C# is very similar in syntax to C++ so you might be able to find a code translator or make one yourself using regular expressions.
You might find that Unity has less of a game framework API than Unreal so you might need to do more coding yourself. e.g. Unreals FPS game engine background.
Not 1/10th. You can get that writing mathematics-heavy code in Python, without C plugins, but not C# at least
Blueprints may have much lower performance than C++, but if it’s used correctly it’s still fast enough (glue code, occasional changes, initiating subsystems which are in the native portion of the engine). But Unreal also has “nativized BPs” which have far better performance. Context switches between BP systems and the rest of the engine can still cost time (or really latency/response time) in speed-sensitive cases, but not nearly as bad.
C# was reported to be within 80% of C++ code a number of years ago (by an employee of Unity Technologies), so it’s far from awful. The JIT code is even better now. With IL2CPP producing native code, the main cost is again context switches, and the deeper the compiled code goes the less there are of those. Just write sensible code which does its thing in as little time as possible if it has to run every frame.
You wouldn’t want to or need to rewrite something without measuring if there really is a speed hit first (or when you start to notice batteries dying faster, if targeting mobile). Profile everything, and consider other ways to write it, then consider writing native code if you can’t get it to perform well. This applies to any engine.
C++ won’t always be faster because it’s not just the compiler that determines performance. A skilled C# programmer can very easily write code that is superior to that of an unskilled C++ programmer. Switching to a faster language will only get you so far.
And is also unsafe c# and .net 7.* and compiler improvements going on with UT that bridges the gap to c++ performance for gamecode and less gc, without all the headaches of having to write it with c++.
I would only consider UE for a game with a team > just me. Otherwise UT is far better all around really.
I believe the performance is not a critical difference from the choices of language.
If you are extremely serious about performance, you can pay for source code access license to kitchen your compile to remove build-in modules such as analytics and thin your build as much as possible.
obviously, but i was comparing all else being equal, equal coding skill, similar tasks being coded, etc… but i did read recently that what can slow down C# and blueprints is when they actually have to talk to C++ and translate the code, that it might be better to code a larger amount of the code in C# when interracting with other C# or blueprints scripts than to mix and match a bunch of C# scripts with C++ scripts, but im not sure if this is true… i could very well just be overthinking the performance hit, and my targeted platform is PC with no interest in mobile devices
Even if your target was mobile, the performance hit would be so small that the entire concept is basically a microoptimisation. There’s really nothing to worry about on that front.
I vastly prefer being able to easily see my code line by line compared to the inevitable spaghetti of visual scripting. Side note: I wouldn’t have thought the phrase “inevitable spaghetti” had been used much before, but Google shows 251 results. Hmm. Well now there can be 252.
Regarding switching engines: As much as I have given strong thought to switching over to Unreal Engine several times now, I always end up sticking with Unity. I know I could use C++ in UE instead of blueprints, but I also enjoy the speed of writing 3 lines in C# to writing 10 lines to do the same thing in C++.
As far as whether the speed of the code is different between engines, it totally depends on what you’re doing with it. Unless you’re an expert code manipulator/optimizer, I don’t think it’s going to even be an issue. Check out some of the bigger games made with Unity, and see if they meet your speed expectations. If so, then there you go.
For most games, most of the time, script performance won’t be your major bottleneck. High level optimisations are pretty straight forward, and can normally fix most script performance issues.
i notice people fairly new to blueprints do end up with a massive spaghetti mess of tangled and convoluted “wires” pointing to every direction, but thats mostly from people who do not understand how to organize it by creating custom functions or custom events to point to another piece of text later on in the code
for example, some of the coding i did had jumping decrease stamina, and sprinting as well, unorganized, you would have to individual write (or copy paste) the whole stamina regen segment to both strings of visual script or drag wires across the screen from both of them to the same regen segment, just as an example, but i set up the 5 second delay and regen phase to a custom event that is called by the above two events at the end, so no convoluted tangled mess of wires
im curious though that outside of preferring C#, which i dont mind at all either, why were you considering going to unreal?
Yeah I’ve seen some pretty crazy looking blueprint setups, and from what I read it’s pretty much a given that you’re going to end up with some spaghetti the larger the project gets. I’m sure someone who enjoys visual scripting could make it all work, but I’m less of a visual person when it comes to code.
I tried out Playmaker (visual scripting for Unity) in the last game we made, to see if visual scripting was better for me. Although it made things quicker to prototype, I ended up moving most of it to code anyway because it got too convoluted. So yeah, depends on the person, of course, but for me I’m not so into it.
Been using Unity since 2009 and would like a change simply for the change. Different work flows yield different challenges, and different challenges yield more creativity, for me at least. I’m also getting really frustrated with the direction the store and other things are going.
Just started working on a new game which is heavy in environments, and thought maybe Unreal would be the one this time, but again, it makes more sense for me to stick with Unity rather than learn an entire new system. And honestly, reading what people have said about Blueprints, it kind of turned me away from Unreal. I just don’t work well with visual scripting. I am still on the fence, though, and tempted to switch over just to see how it all pans out.
The have been changing it and it’s no where near as good as the old store. There have been a number of threads about how bad it is. They did the same thing with the job forum here. There used to be a section of the forum where one could easily find projects to work on or find people to work on projects. It worked great. They removed it and created Unity Connect to take its place, and, uhm, yeah, again, there are a number of threads about how bad that is.
Basically, I wish they would stop changing useful things just for the sake of changing them. As a long time user it just gets frustrating. Change is good. Bad change is… not.
If you’re using C# hashmap and it is slower std::unordered_map, then being more skilled won’t help you.
I hit this kind of problem before.
To the OP:
C# scripts are going to be faster than unreal blueprints. For majority of projects you do not need supreme performance anyway, given the power of modern hardware.
Upcoming Unity versions allow you do write the fast code by default in C#. Their new compiler technology “Burst”, generates even faster code than current C++ compilers, according to Unity.
What seems to have even a more significant affect on performance is making use of all available CPU cores, which now is possible due to the C# Job system.
well, the current CEO of unity was fired in complete disgrace from electronic arts, after changes to the company much of which shafted the consumer to try to squeeze more money on them (incomplete games like mass effect 3, selling parts of the game separately as DLC to charge more, online pass, etc) causing EA stock to crash by 70%… so if unity is making unpopular changes that are pushing people away i wouldnt be surprised… heck, im quite disappointed to see their business model has changed from a one time cost of like $1,500 to now a subscription that costs an individual $1,500 per year… im not sure how i feel about that compared to UE4s 5% royalties, but the $1500 one time fee was highly attractive