277 points · by Eyas · 6y ago · 121 comments
It's easy to get started, iterate on ideas, there are tons of examples of things online.
That said, it's not without its warts -- APIs change constantly, which means many of the examples or assets you find are no longer functional or need to poking to get working. Sometimes things just... behave oddly... in the editor. And the story around collaborating with friends is still not great (though a free tier for Unity Collaborate has helped with this a bit.)
If you haven't messed around with Unity, I encourage folks to give it a try. The new Universal Render Pipeline stuff they've been building is really nice for a solo/small team project.
Assets load differently, in surprising ways. Materials may work fine in Editor but not in Client.
Code executes differently. Timings are different, the Editor shares managed Heap with the Client, and so garbage collection is different.
And so on.
Rule 0 with Unity: _do not rely on the Editor for testing_.
I agree that you can't easily use editor performance profiles though; there's far too much editor noise.
I think with time/experience you'll learn to spot what to ignore (frame lengths, etc) and what you could count on. And just to test fully-build games often, and across clients.
* C# does something similar with hash across builds (so you don't depend on serializing/deserializing hashes and expect them to work; they want the freedom to change hash functions).
Unless you plan on developing an open source game or need absolute total control over your project I wouldn't use Godot.
The greatest advantage of Unity is anyone can develop something for it very fast. The worst part of Unity is anyone can develop something for it very fast. An asset developer might build something which he or she doesn't actually update, or has a nasty habit of completely breaking your project.
The one thing I don't like about Unity is the lack of quality control with assets. Some assets will give you a nice foundation for a fantastic project, others will set you back days. Asset authors are almost always either absolute Angels, who will go out of their way to help you and if they can't offer you a refund.
Or their jerks, their assets don't do what they promised and they'll refuse to refund your money. If I could fix one thing about the unity ecosystem, I'd tell Unity to give asset buyers a few no contest refunds . I probably spend about 1000$ on Unity assets per year.
The one time a $15 asset ends up not working correctly I should be able to get a refund without begging the author for it.
Plus it's essential to understand what your goal is. Do you want to actually ship your game within a reasonable amount of time? Or do you feel like creating a project primarily for learning, or to just share the code on GitHub?
If you want to ship a game, either use Unity or Unreal. These are the only two engines which are well supported enough where you can get something done within a reasonable amount of time.
Open source engines are cool, but there is absolutely no expectation of things working as well. Let's say you want to build a project with Godot, and it's going well so you want to publish it to Switch. You're going to run into a ton of problems off the bat, one open source projects tend to not support closed apis which council manufacturers force you to support. So you're going to have to build your own integration there.
Vs clicking a build to Switch button with Unity.
Honestly I can't say enough good things about Unity, you have an amazing amount of educational material they publish. And for the most part I've been able to buy assets for $50 or $100, and save myself 80% of the development time on my projects. You aren't going to have a good time with Unity if you're adverse to buying assets.
So you're saying we're Waiting for Godot?
Very surprising. ;-)
What important features is Godot missing that Unity has?
https://docs.godotengine.org/en/stable/getting_started/step_...
After spending literally hours trying and failing to get Unity to run at all on my computer, I downloaded Godot and ran a demo project in 5 minutes. It’s a great lighter-weight option for software developers who want to feel a little closer to the code.
Both are fine, but if you're going to pick one, I'd suggest Unreal by a long shot. Switching between the two is tricky and is likely to make one feel whichever they started with is more intuitive as the UI design is pretty different for each editor, but both feel fine after a short effort. The main reason I'd vote for Unreal is that Unreal feels like it's getting better at a noteworthy pace, and Unity is stuck in a one step forward, one step back pace.
* C++ (unreal) is not as fun as C# (unity). But Unreal's blueprint system (a visual, node based coding system) is much easier than both, and super helpful in the game dev world because it makes the engine API easily discoverable. Not good if you want to write a list sorting algo. Very good if you want to make a character jump. Dispense any preconceptions they may have implied about "not needing to know how to code" to use blueprints. If you can't code you will likely burn out trying to use blueprints without grasping the fundamentals of coding, because blueprints are just code with visual syntax, and syntax is not the hard part of coding.
* Marketplace assets on unreal seem way better. The high end stuff is better. The free stuff is better. The number of high quality textures and prefabs you get for free via quixel in Unreal is astounding.
* Unreal requires more computing power, and I found the editor crashes more. That's not so good.
* Networked multiplayer is just broken in Unity, versus integrated into everything for Unreal. This is huge! for shame, unity.
* Unreal's financial terms are more indie friendly (free for first million of revenue)
* Neither is going to make or break your game dev experience versus the other.
I pick Unity every time. Yes it has many many issues, but as a hobbyist you'll pick a version of it and stick with it. Improvements isn't where the end goal is at, it's at allowing you to deliver a game/product on a given version.
C# is definitely a lot better than old-school C. Unreal C++, everything is just extremely clunky and verbose. Sure there are blueprints, but then now there are free alternatives for the same on Unity as well (although not working as well). If you need to know something there are 10x more free resources for Unity. If you need to buy something, there are 1000x more items on the Asset Store.
You don't need Unreal for Quixel, you can also use it in Unity. You can also use Substance. Sure there are many useless assets, but there are also many many many awesome assets in Unity. Use them.
Both editors have issues. I won't comment on Unreal. Unity's can be a real piece of work sometimes. They all give you issues and make you go arrrgh.
Networking. Unity has nothing by default, it's all in the Unreal corner. If you want to do it in Unity, install Raknet, cloud options, etc., you'll have to figure it out. It's a big ball they have no clue about.
Financial terms, let's see. Both are ok. As an indie first you need to produce, then it's about the fine print. Both are ok, really.
Last point, 100% agree. It's about producing a game. Both engines will fight you hard if you try to produce anything outside their default mindsets. Unreal by default focuses more on fps action. Unity is more open. but GameObjects are extremely heavy and restrictive. You'll need to figure out instancing (until whenever DOTS becomes production ready and useful). Other issues, newer options like HDR isn't supported in Unity by default yet, so if you're heading that way it's definitely not for you.
Unity's licensing model has always been that developers or users must pay for their own license (for an asset or non-free subscription) unless they are part of an entity's license. Unity clarified that only employees of an entity, or subsidiaries of an entity and the subsidiary's employees, are covered by the license.
This is generally always how it works with software licensing: independent contractors, by virtue of being separate businesses, must pay for their own tools and licenses (and indeed, that is one of the factors in the independent contractor test under federal US law).
However:
Programming in Unity is quicker and easier.
* In Unreal you have to choose between Blueprints (which have some issues) and C++. C++ compile times are slow. Unreal supports hot-reloading of C++, but it frequently breaks stuff, so it's safer to save your work, close the editor, and then recompile and restart the editor. It takes a few minutes, which really slows down iteration times when you're tweaking a feature. If you have a bug in your C++ code, it can crash the whole editor, and you'll lose any unsaved changes.
* Unity's architecture is simpler, lighter, and more pure. Unity has GameObjects. They hold a collection of components. An empty GameObject has very few functions or variables. GameObjects are purely containers; you don't inherit from them, you just make components. Unreal has Actors. An empty actor has 448 functions. sizeof() and empty actor is over 1 KB. You inherit from actors, and functionality is mixed between inheritance and components. This flexibility may sound like an advantage, but I find inheritance tends to cause more problems, especially in conjunction with Blueprints. Unreal's built-in classes (AGameMode, APawn, APlayerPawn, ACharacter, APlayerController, AGameState, UCharacterMovementComponent) set up a somewhat complex architecture for you that's strongly biased towards the FPS genre.
* Unity's API documentation is miles ahead of Unreal's. The community is also larger which makes problems more googleable.
Blueprints kind of suck.
* Blueprints look friendlier to non-programmers, but code is easier to read and write for anything complex. Even short things are often simpler in code. For comparison, here's the same function in Blueprints (https://i.imgur.com/86rt8qp.png) and C++ (https://i.imgur.com/7HSnlR9.png).
* Blueprints are saved in an opaque binary format. This doesn't work well with version control. Unreal has a diff tool for Blueprints, but you can't merge them. On rare occasions, a Blueprints will get corrupted or bugged and your only option is to revert it in your version control (we've had Blueprints crash the Unreal editor whenever you open them).
* Blueprints are an order of magnitude or two slower than C++.
* Blueprints lack a lot of functionality compared to C++. Only API functions that are intentionally exposed to Blueprints can be called. You don't have anything like functors or lambdas. There's nothing like templating or generics. While there appears to be a dropdown to make Blueprint functions public/private/protected, it doesn't work (it literally has no effect).
* Making C++ code useable from Blueprints is extra work. It can be tricky to write classes and interfaces in C++ that can be used from either C++ or Blueprints. It's not much of a problem for a single concrete class, but it gets tricky when you want to make things flexible with interfaces.
Unity has more resources for developers
Epic is slowly closing the gap here, but Unity has a bigger community, a bigger asset store, and better docs. For models and sounds, we often would use the Unity Asset Store for our Unreal projects. Unfortunately, that's not possible for code plugins. Stuff like Amplify Imposters and FinalIK just doesn't exist on the Unreal Marketplace (although looking again, the Unreal Marketplace recently got a Fabrik IK plugin, so maybe they're catching up).
I don't agree with this. I do think C# is an easier language to follow, but Unity's game engine API has less stuff built into it, which is a far more time consuming element to work around. If you want to say, launch a projectile, Unreal has the projectile movement component that you can slap on something. Unity you'll need to implement it yourself. I went from Unity to Unreal and find the number of things that are automatic vs. manually implemented is a way better time saver.
> Blueprints kind of suck.
I've never had them run too slowly versus code. I do miss lambdas. But I think blueprints have some advantages that code does not. It's incredibly useful to visually see at a glance what functions are pure with no side effects. It's lovely to be able to collapse large sections of code into nodes with long descriptive names that you don't need to look at. I code in blueprints as much as possible. I low key wish I could move my python jupyter notebooks from work to such an environment because it makes the pipelines so easy to follow. That is, I find it way easier to produce excellent documentation for them than with code. Mind you many people seem to have the opposite interaction and create lovecraftian spaghetti horrors.
I don't quite follow what Imposters does, but I think this is likely to be outclassed in UE5 with its nanite and lumen. IK solvers are just a part of the engine via Control Rig. Haven't used em though.
To each their own though. Unity is good. I just have doubts about its future management.
> It's incredibly useful to visually see at a glance what functions are pure with no side effects.
You can use the const keyword for this in C++.
> I code in blueprints as much as possible.
I also code mostly in Blueprints. The fast compile/iteration time is the main reason. But it has it's downsides (code review is largely impractical, no merging, physically much bigger and longer to read than equivalent C++).
Imposters and IK are actually both things that Unreal has built-in, but the built-in versions are limited or poor quality. Unreal has two-bone IK, and more recently, a FABRIK solver, but it didn't support multiple end-effectors or joint constraints. So basically, if you wanted something like a multiplayer VR game where the character poses somewhat realistically to match the positions of the headset and hands of the player, you couldn't do that. The main use for Unreal's two-bone IK (which was the only built-in IK for a long time) is for smaller tweaks like adjusting the position of a characters foot to be in contact with the ground.
UE5 looks very cool. I'm looking forward to its release.
One thing that’s interesting to me about Unity is AFAIK it bakes the Entity Component System pattern into its core. Any good guides or resources on this?
I found Robert Nystrom’s excellent book a good resource for this (http://gameprogrammingpatterns.com/component.html) and even wrote my own post on the concept to help crystallize my understanding (http://ripplega.me/development/ecs-ez/). I’m interested to see if there’s a good authoritative Unity-specific post on the topic.
Don't know how close these patterns would fit Unity, but I would suspect a large overlap.
I’ve switched over to the Heaps engine by the creator of the Haxe language.
In addition to the compile time issues, I found myself constantly fighting the Unity way of doing things in that I prefer doing things in code as opposed to using the editor.
Also, I think it's worth mentioning that if you care about the longevity of your game (like 10+ years into the future), depending on the Unity runtime being compatible with future OS versions is also a risk.
Then again, the alternative requires some pretty hefty engineering chops and prior knowledge of a whole host of lower level concepts and APIs.
EDIT: Also Heaps is the choice of Dead Cells dev and he's written about it some here: https://deepnight.net/tutorial/using-my-gamebase-to-create-a...
It's not that they make it impossible upgrade to a new major version, but yes it's not prudent to switch between major revisions of a game engine deep into development, that's not unique to Unity.
Game engines don't have the JavaScript style churn where your library is dead if it doesn't do something major every month
Unreal Engine 3 => 4 was 8 years?
Unreal Engine 5 is going to launch next year, almost 7 years later
Unity 4 => 5 was 5 years, and then Unity switched LTS releases which are getting updates for 3 or 4 years?
-
The improvements that come with major versions just don't make sense to try and pull in on a game deep in development either
I mean look at this year's releases, a big focus has been the new render pipelines, but are you going to rip out your game's entire graphics stack mid development and redo every single shader and material?
Unless you really have a good reason, probably not...
You can pull new versions while under development. I've been on a team that did it and it was not fun. Usually involved some poor soul pulling the short straw, spending ~6 weeks 3-way merging followed by a large uplevel commit that breaks everything. This follows ~4 weeks of bugfixing at which point you start the process again since a new major version was just released.
Of course you can not update, but then you might be relying on half-finished/half-broken features that could be fixed just by upgrading.
Also, the whole upgrade process itself could be improved if they put time on it. There's nothing inherent to game engines that forces Unity to have so many breaking changes all the time.
I didn't even try porting my 10 year old XNA game until a year and a half ago, and I was able to get it compiled and running with 90% functionality (again shaders and storage was broken) in just 24 hours.
And they just had a major new release that, among other things, supports .Net Core, just two months ago, yet I'm still able to do this.
(You do need to turn off Auto Refresh though, no idea why they think having that setting enabled by default is a good idea.)
Changing a single line of code can take close to a minute on a medium to large sized game under a 2020.1.
Using something like Heaps where you can compile a large game like Northgard completely in 4 seconds is a completely different experience.
For me, I realized that wanting to "keep it all in code" is a learned habit, and part of why I learned it is because the tooling when everything in code is just so much better. I can navigate references, etc., count on compiler errors runtime errors, etc. But none of this fundamentally required me to keep it all in code _if_ the tooling allows it. With ~2020 it feels like the tooling is getting to that point.
I don't think Unity is nearly at that point for my use case. Part of the problem is that I tend to build games that require a lot of procedural generation and user created content.
I basically end up needing to build some kind of level/content editor for my end users, which removes a lot of the value Unity brings to the table.
If you're using procedural generation or using an external tool to design your levels, then the Editor definitely becomes a hurdle.
Baking work into serialized objects at build time (or dev time) is your friend. You should learn to love it.
There are some terrible things Unity does but loading a large block of prebaked assets is one of the things Unity is fairly good at.
If you use Microsoft’s DI Extension it gets even easier.
But don't use dependency injection. Unity's Scene/Prefab load/instantiation is already a form of DI. Using another causes issues with juggling multiple lifecycles.
You also lose the ability for Unity to prefetch assets because Unity can't inspect the dependency graph if it's not done through the asset system. Instead you hit situations where you're loading several objects and running DI code over several frames when unity could have loaded everything at once.
I am not a game dev, more app/audio/web, but our app uses Unity for the 3D and interactive video lesson playback parts and recently I’ve been refactoring the video part, which is a perfect candidate for building out with unit and integration tests. It took a lot of digging to work out how to use the Unity unit test stuff effectively as there are really just a few toy examples out there, same with async/await (and the unit test runner still cannot handle async/await in tests!).
I guess maybe it’s a culture thing to some extent, unit testing maybe isn’t as prevalent in games for whatever reason? Once I worked out, as you say, that I could move most of the logic into plain C# classes and test them much the same way I would any old business logic, things became much easier to deal with.
I did think about using DI but in the end found that passing GameObjects in via the IDE and public members as the other comment says sufficed for anything which is a GameObject, and the other (plain class) dependencies I am new’ing up in a top level Manager class and passing down through the constructor, and using NSubstitute to pass in mocks in the unit tests.
I might write up my experience/findings some time when the work is complete.
On the whole, I do think Unity is great, I’ve seen how fast we were able to build out a great looking experience and it’s pretty easy to figure out. C# is a really nice language too. Just a shame that more “modern” dev practices are not actively promoted, and parts like async/await and unit testing seem to be left half-finished.
One thing I noticed from just skimming the tutorials is there is a lot of Unity editor specific creation of stuff. How much of that is the actual game programming? Maybe web dev is headed in that direction if we ever eventually map Figma to components, where you kind of define it via a GUI. Seeing that felt a little off putting since I’m used to working with a tight scaffold that’s mostly code.
Godot looked less GUI intensive so I was thinking about digging into that instead.
I guess another way to pose this question is, do I need to get over this and accept this is how games are made?
I kind of wrote about "keeping it all in code" and why it isn't desirable in the second installment: https://blog.eyas.sh/2020/10/unity-for-engineers-pt2-six-pra...
But once you get the placement / connection / injection right, you'll still be spending the bulk of your non-testing development time in the code editor.
The second installment (already published) talks about some of these best practices, but it doesn't quite dig into architecture just yet.
One thing that I am struggling with though is settling on good ideas for general architecture for structuring the logic, and then doing things like communicating between entities/objects in a scalable way. Not everything that needs to communicate exists in a nice parent-child relationship - occasionally you need to communicate "across branches" in a hierarchical tree when there is no other interactions such as collisions etc.
You can get a long way with just cobbling stuff together, but eventually you get into growing pains where it becomes a mess.
The "best" solution I have so far is awkward "god"/"manager" objects that act as glue to let everything access everything. There has to be a better way?
The nice with with Unity though is that the logic is in .NET IL so it is trivial to see how people are doing things and learn.
Try organizing your code around the data your components have to work with and let your code react to changes to that data. Using Scriptable-objects is a great way to facilitate this model, because with them your game components will reference data assets instead of other components, reducing dependencies, which gets harder and harder to manage as the complexity of your application grows.
I can really recommend watching Ryan Hipple's presentation titled "Game Architecture with Scriptable Objects". [0]
At our studio we've built a framework based on these ideas for a high-complexity game project and we're very happy with it so far. We have a clean and well-performing codebase that's easy to maintain and test, because no sub-system has any hard dependency on any other sub-system.
This was useful.
The tl;dr for anyone who can't spend an hour watching (why are so many Unity things done as videos?!?! so infuriating!) is that you use "Scriptable Objects" (new to me - this is a first-class thing in Unity) to store common state and so break statically defined dependencies between Game Objects by having them share the Scriptable Object rather than reference each other.
So you might have a Scriptable Object that contains the player's score/coins picked-up/zombies killed etc. On its own this is conceptually basically just a number/several values/etc wrapped in a small singleton class. You then reference that Scriptable Object in your player game object/script that will mutate that value. Anything else that needs to know the score/coins picked-up/zombies killed (e.g. UI code) references the same Scriptable Object.
So now two separate parts of the game share the state without being statically bound to each other (they are only bound to the Scriptable Object). Plug in as many or as few new components all using the same state stored in the same Scriptable Object and nothing else needs to change as they only share the Scriptable Object. No references to other game objects required.
You can do the same for events - create a Scriptable Object for an event (e.g. PlayerHurt or PlayerShoot etc). Since Scriptable Objects can contain code like any other class, you can have GameObjects register their interest in this shared singleton event by calling "PlayerHurt.RegisterListener(this)" etc, and then have another GameObject trigger/raise/activate the event ScriptableObject ("PlayerHurt.Trigger()" etc). Neither side know about each other, so you can plug in as many or as few listeners as you want. The talk uses some extra cleverness to use a UnityEvent to allow for a function call in reaction to the event being triggered - this means a lot can be done directly in the unity editor, but that seems separate from the main secret-sauce of the scriptable object as the mechanism for shared state.
Site here that basically repeats the video nearly verbatim: https://unity.com/how-to/architect-game-code-scriptable-obje...
Cheers!
Don't be too worried about mediators though. Games are a little bit different in that you typically want to act on a shared world. If you have systems that act globally on the world then you're just matching the data that exists. Even the physics system itself is basically a singleton that's mediating interaction.
This can get kind of tricky if you use a lot of procedural generation or prefabs where for some reason you can’t immediately set the reference to that other GameObject (for example, the player has no gun yet). In those cases you should try to set the reference programatically, such as when the Player picks up the gun. You might have a reference from the Player to the HUD, and when the player picks up the gun you set the Gun’s UI reference via some SetUiObject(GameObject ui)
I end up relying on asset-ized SOs to do a lot of this. When communication between any two nodes is mostly one directional, events and triggers work great. (Ryan Hipple has a great talk on this, just search for "Ryan Hipple ScriptableObject".
Some things I would really like to figure out are some of the idiomatic ways monobehaviors are structured, the variability between them, how best to separate game logic from implementation specifics, and best practices for reusability in real life, beyond what most of the tutorials teach.
Subscribed. Looking forward to seeing the next set of articles!
There are two kind of opposing directions I see a need for:
- "Beginner Unity" take tailored for an Engineer. E.g. let's talk about the input system, frame-rate independence, overview of rendering/lighting, a high level overview of the editor, etc. And get that out of the way.
- Satisfying what I might call a thirst for idioms/best practices from a SWE perspective. E.g. separation of concerns in MonoBehaviors, using ScriptableObjects, etc. Also maybe overview of things like "Should I still use Git with Unity or look into Collaborate?" and the like.
My current sense is that I'll end up toeing the line between these two. But, regardless of this specific series, I enjoy writing about best practices and software patterns in anything I'm working on, and Unity is no exception -- so stay tuned!
What is your take on that?
Unreal is used for on-set visualization (see e.g. the Mandalorian) but Unity is frequently used for pre-viz/planning work because you can just literally drag and drop things in and run them (see e.g. the Jungle Book, from the same director).
i feel the money and R&D that will span from that in the unreal engine will allow them to totally crush unity. already today most of the modern games made with unity are 2d or average 3d games.
Most of the modern games today aren't made with the Unreal engine...For example, among triple-AAA studios, EA, Rockstar, Activision, and Ubisoft all use their own engines (note: Activision uses Unity for some of its games).
Epic already makes a few hundred million each year from Fortnite. The relative pittance they get from Hollywood studios isn't even a drop in the bucket and generally won't effect the pace of development of Unreal, though it has driven Epic to put even more effort into making Unreal a better component in Hollywood workflows. However, this effort won't have much, if any, impact on game production since the workflows are completely different.
Just played Tony Hawk 1+2( remaster by Activision) , which uses Unreal.
It's going to heavily depend on the team and the project.
Generally lower spec games are good fits for Unity, while Unreal is best for higher end ones
Still, the game engine market is unlikely to be dominated by a single player anytime soon. I think you'll continue to see something that looks rather similar to the mobile OS space: lots of players, but ~2 dominate the space. Unreal's revenue cut is also a lot more prohibitive than Unity's, so you'll also keep seeing a healthy indie ecosystem (which translates to a community, assets, etc.) in Unity.
A lot of Unreal's recent investments are incredibly impressive. Especially with better rendering and realtime raytracing. But Unity is also making some big investments, DOTS (see https://unity.com/megacity for example) comes to mind in particular.
> What is your take on that?
I think this year has demonstrated the appeal of games made with Unity - "Fall Guys" and "Among Us" have been very successful over the summer (despite "Among Us" actually coming out in 2018).
I've tried to get started with Unity a few times before and have the exact issues described. I know how to program, just tell me how to do it in this IDE!
I got up and running faster with Unity in 1 week. But after 1 month with each I found unreal to be easier.
A major problem with both is that the learning communities are terrible, because they're filled with wannabes who, while well intentioned, have no idea what they're doing. Question and Answer forums are plagued with dumb questions that aggressively try to assert that they need to know X when actually the problem begins at A, B, C. Youtube tutorials are filled with hilariously bad narrators who spend an hour trying to demo a basic concept and then for unfathomable reasons, do not show the final result before ending the video.
Find a single good set of tutorials to go through the process of making something (anything!) and an active place where competent people discuss things. Googling, unlike most coding problems, is not your friend if you want to find best practice stuff.
For Unreal, I thought this guy was decent: https://www.youtube.com/watch?v=DywBqQtTHMo
I only did the first fifteen or so before I decided to start figuring stuff out on my own. The unreal slackers discord channel is the best place I've found for asking knowledgable folks.
https://docs.unity3d.com/ScriptReference/SceneManagement.Loa...
https://gamedevacademy.org/a-guide-to-handling-huge-worlds-i...
Sure , you can add more scenes . I've never done it to create terrain though. Another trick is to not destroy certain game objects on load.
See “mode” parameter—additive. This doesn’t answer how you unload.
I was using the ECS for the last 2 years, and I wouldn't recommend it to anyone who actually wants to get something into production. My guess is it will be somewhere late 2021 or 2022 before it's actually production ready.