Watch This Before Working on a Big Game in Unity
Vložit
- čas přidán 7. 06. 2024
- Making huge games in unity can quickly lead to problems - hopefully this video can help you to avoid them.
Links:
CrossScene Reference / GUID Based Reference:
github.com/Unity-Technologies...
Material Property Override:
github.com/Unity-Technologies...
NavMeshComponents:
github.com/Unity-Technologies...
Video Devlog by Robert Thomson:
• ZeroTag Devlog OMEGA
Timestamps:
00:00 - Intro
00:39 - Hardware
01:13 - Lighting
02:09 - Pro Builder
03:16 - Editor Performance
04:45 - Runtime Performance
06:53 - Planning for Performance
07:59 - No Automatic Systems
09:01 - Finding Close Objects
09:57 - Physics
11:22 - Non Player Characters (NPCs)
13:05 - Memory Management
13:48 - Reuse Assets
14:35 - Coding
15:01 - Profiling
15:59 - Keep Things Simple
16:27 - Summary
17:42 - Outro
My Twitter:
/ leorid4 - Hry
And now i have a question, what’s a big game ?
After uploading I realized I never specified it in the video. Basically every game where you have a big enough (or complex enough) connected game world that you have to load and unload content to achieve 60fps in the build.
In my specific case it was when we had more than 3million triangles on the screen while going through the world, at about 100k GameObjects, about a map size of 2km x 1km. At that point lightmapping stopped working, occlusion culling broke, it took 70 seconds to recompile or jump into play mode and we had less than 30 fps.
I profiled the game and editor for two months and tried absolutely everything to fix it. This video shows what I've found out. What works and what doesn't work. Recompile time is now about 10 seconds, jumping into play mode 5 seconds, navigating the scene camera is smooth, the game runs at ~70-80fps at 4k with an RTX 3070 and 6-Core CPU and in 2k on many systems (playtesters had no issues). And it's now scaleable, we can add levels without any slowdowns and we can collaborate without merge conflicts (the last point took another month, creating the multi-scene setup).
Thanks for answering !
@@johnleorid Amazing! Thank you for sharing! :D
@@johnleorid 3 million? my game exceeds 30 million very often lol
@@TYNEPUNK *3 Million, despite occlusion culling xD
When using a game with a large open world: keep in mind the problems with float imprecision. If your camera gets away more than like 2000 units from the origin, animations can start to flicker and shake. Look up various methods of "origin shifting" to solve that problem by moving the scene dynamically closer to the origin point.
Good point!
Well, origin shifting is one way to do it, aswell I know teams have just modified the engine they're using to use double-precision coords (CIG did this with CryEngine to get their space, yknow, space-y without having to deal with MMO synchronized world origin shifting, also Epic did this and UE5 natively uses double precision coordinates out of the box now), and then your distance limit becomes so ludicrous that it's barely even worth considering unless you're making a space sim in which everything must always exist in the same scene at the same time. However, with Unity, you need to pay them ridiculous sums of cash to get access to the source code in the first place to even begin on a change like this (which is absolutely insane on its own and anti-consumer as hell when every single other major engine has source out of the box), so YMMV if using this engine.
@@xanderkyron I never saw this as much of a hassle. The C# code can run just fine logic with using custom double Vectors. Custom Netcode can also use double precision. Just anything that has to do with the client visualization and local physics needs to be converted to 32bit float. But then again, the relevant scene is near the camera anyways. Things further away would be turned off or rendered in a different way (second scene camera to render a scaled down solar system, that is the backdrop when travelling for example). The world in a huge game like Star Citizen is also not just a simple scene with objects plopped in, but a more complex process to generate local scenes on the fly. So its also possible in Unity with the right approach.
Of course, just compiling all those systems with using doubles would be the cleaner approach, if the engine allows that.
Gaia has a floating point fix function, takes care of this auto 👍
I noticed this while working on a scene that would move the focus of the scene to a location, which would never be reachable by conventional means, as a way to do some tutorial cutscenes without having to load an entirely new scene... my animated model was shaking like she was on a speedball drug or something. My solution was inevitably to move these constructs closer to the bottom of the terrain mesh. It didn't make any sense to me why the issue was resolved by doing this and it's still not something I completely understand but it is what it is.
I think one of the biggest hurdles (atleast for me) working with larger projects is to say "no" to things I want to have in the game. There is usually sooo much that I want to add to the game, there is a need to mash all those idéas into doable tasks.
While working on the event system video, I am thinking about a video about scoping and planning a game, the whole preproduction phase that a lot of devs seem to skip. (I am guilty of this too, as well as feature creep)
@@johnleorid that would be awesome
Honestly, this is a good problem to have. My boss (20 years of xp in the industry www.youtube.com/@SamuelAsherRivello) was telling me stories of some people that were excellent at coding but couldn't come up with the visual aspects of the game, which is honestly what should drive everything anyway
@@alexandratrenkova9339that's me all the way lol trying to train myself to be more Creative, etc lmao
Me making a 2D tic tac toe game: "Ah yes this is relevant to me"
Even five minutes into the video, I could barely believe how densely packed this video is with useful information. Thank you for this great video.
This is quality content. Well done.
It's so hard to find topics about big projects with Unity. I hope you continue to share your knowledge.
Cause Unity is trash
@@hollownxt1295 not really lol, it's an excellent tool that has some unfortunate limitations. It's a perfectly good engine for games with smaller scopes and for beginner game devs looking to prototype things quickly.
@@jomalomal Unreal Engine for has better and more tools and it’s free…
@@hollownxt1295 Epic take 30% of your revenue
@@Finlzz and? With Unity you’re not getting any
This is very good content. I would love that video on an Event system.
Working on it ^^
@@johnleorid Nice, I would love it !
@@johnleorid cant wait to see it.
yeh i dont get that event system really
++++
This video is amazing. On CZcams the most of the videos about Unity are good enough for beginners or intermediate, but there aren't too many videos about these complex topics. I think that if you could create some videos about coding a big game it should be fantastic! Thanks again for the video
this is really good content, this type of information is kind of hard to find when you encounter an issue related to them, so it's really beneficial to know them before you encounter these issues, just having the knowledge that a solution exists for a certain problem will save a lot of time when you encounter them.
game devs really need someone like you, keep it up I think your the next Brackeys
Haha nice message on the end!
I’m developing a bus simulator for about five years, there are a lot of things that we learn the hard way haha. I abandoned ProBuilder because some updates broke some of my models.
Huge games on Unity will suffer from another problem: the lack of precision on world coordinates. After 10km or so from the origin things will get broken, shadows appear blinking, too much jitter on smaller objects etc. The most common solution is moving everything back to keep the camera near the 0,0,0 position.
Unreal Engine 4 includes a setting for that, on Unity there is a great open code called “Floating Origin”. But performance may be bad if there are tons of rigidbodies. I can’t wait to test a custom compiled version of Unreal Engine 5 with 64-bit coordinates. But I’m procrastinating on that.
True, floating point precision is indeed a problem for games with a big world map.
After I uploaded the video, I realized that I never specified what I meant with "Big Games". xD
But I guess most of what I said applies to a lot of ambitious games. ^^
Wait unity doesn’t have double precision support? REALLY?!
@@saul8510 as a data type it has the double variable. But not for transforms positions, rotations and scale… Every huge map must have its own workaround to “fix” it.
@@johnleorid are you working in big company?
Btw, how to start? What to learn first to be able navigating intuitively In all of this?
@@FirstnameLastname-my7bz I'm working at a company. Not small, not big, just a company. XD
I would suggest looking for "unity beginner tutorials" and you should definitely start small. My first game was ~12 grey cubes and a horribly animated character to jump from one cube to the next one.
Thanks for this content! There is a lot of content about making demos and for beginners of Unity, but really lack content like yours about how to build complex systems and larger project! Subscribed!
Heyho, Game Dev here for Unity. I do a lot of profiling, and we are using Renderdoc. Its an extremely important tool as you can link it to Unity and grab Frames to analyze. It is similar to the Frame Debugger, but much much more indepth.
When we started optimizing we were constantly checking our builds, and with Renderdoc we removed about 1/3 of GPU overhead already.
One important topic to mention from GPU sides are shaders, lights, shadows and texture sizes. But thats probably a whole other video as well.
Great Job otherwise.
Grüße
Interesting topic, good to see more videos about it. I think there are more aspects to it, but these are def. some important ones. The part about the navmesh volumes was awesome, I didn't know about that!
There is something for GPU/shader analysing too, the Frame Debugger, where you can step through separate draw calls and such.
The frame debugger really helps when you know what you are doing. Back when we had GPU performance problems and I had basically no idea about batching, instanced rendering and draw calls and so on, it wasn't a helpful tool for me.
But you are right, I sould've mentioned it.
@@johnleorid hello there im just started to learn and bought gaia pro 2021 that has an option for multi tile terrain streaming but im not a coder but wanne be an artist do you have some tips. Like how to load and unload like building or vegetations only on the terrain tile where the player is at the moment how does that work whithout coding is that possible . And should i do when making the things like you said in your video to only stream load and unload where the player is like vegetation or buildings. I know that with npc s and crowd you can spaan them in when enter a region by triggers but what about buildings props vegetation etc is that possible
The Unity Frame Debugger isn't very good. Use RenderDoc (or Pix or Nsight) instead. Right-click the game tab to get a button for taking a RenderDoc capture.
@@johnleorid can i have a video or some informative links about these topics (batching and stuff) too. Would really like that
I would greatly appreciate another video on the event system you mentioned and a more in-depth look at organizing code for a complex game like that. Excellent video btw.
Thank you for teaching about the material override. I had no idea that was a thing and makes things SO much better than having to create another material instance when I just need a slightly different material.
In V2022.1 there are material variants which provide pretty much the same functionality - but afaik they are still assets you have to create.
This video was such a relieving change of pace, I instantly subscribed.
Some real helpful things to consider here, even though I personally don't intend to make a "big" project and instead focus on smaller contained maps myself, keeping all these things in mind is still important and good practice.
Will subscribe and look out for more helpful vids from you. :D
Videos like these are legendary and must saves. This talks about many things you don't often hear about in 99% Game Dev videos. And it was purely knowledge, and no bull shit.
This is an amazing video - thanks! Would be interesting to see you go into more details on some of the techniques you mention, like the events system. These optimization videos are great 👍
Great explanation and I learned a lot from this video. Would love to see more content, e.g. the event system you mentioned
Amazin video, thank you so much for working on this, it is so hard to find actual intermediate/advance topics about Unity.
Loved it!
Very informative video in a concise format, great! I'd also love a video or two about Coding for a Big Game. Keep it up!
Man these are such knowledge BOMBS! I'm making a small to medium-sized 3D project and a lot of what you said applies!
Also you nailed that outro
Bloody brilliant content, thanks for uploading and looking forward to more insights in your future videos
I would love to see more videos like these as well as more in-depth content on the coding and planning side of things. Event System sounds good. I'd also maybe like to see some dedicated videos on the topics you discussed here that go more in-depth.
This is golden information. Keep these things in mind any time when doing any FP game that has any asynchronous loading
Definitely interested in learning more about coding systems! Great video mate
I would really like to see a video diving more into the event manager and organizing your code. Great video, you held my attention the whole time and earned my subscription. Keep up the great work!
Please make more such quality content if you get some time it is very helpful for newbies like me (learning unity currently and will join company soon) this helps alot to understand many situation and stuff.
Thank you for the video! Would absolutely love to see more vids from you
Subscribed for this video, well done!❤
This is very informative, Thank you, great content!
Great stuff I’m helping my friend with his open world game and I have never made a large game before, glad to know there is nothing too complicated that I didn’t already know.
This was very informative. Thank you for the video!
This is a 10 years of experience and knowledge compressed into a single video. Would be great to see the video about code optimization!
Very useful content. Thank you and your patrons :)
Very very informative video, I would love to see what you got more
Amazing video, thank you so much. Subscribed in the hope that you'll put out a coding/event system video 😁
Thanks for the insights! Outro made me instantly like&sub. :)
One of the best Unity videos I saw. Unfortinaly I had to learn some of those lessons the hard way, cause this topic isn't covered enough.
This was a really great video. I’ve only now started to dabble in unity. I don’t want to make a huge open world, something more sizable, but I’m a junkie for optimization and figuring out how to make things better. Really enjoyed the points you brought here, I’ve spent most of last night googling about them and learning alternatives lol😊
Good video! These concepts are crucial for any game developer not only Unity devs. Unity is "good" enough for bad games and if more people like you will teach others this low levels stuff. Then we all, as gamers will benefit from it as well as the Unity's reputation xD. Keep it up!
Awesome video with fantastic information. Thank you so much for making this ❤️
Really nice video! Taught me some stuff I didn´t really think about.
Finally "advanced" tips. Thank you so much, those are really helpful!
This was really helpful, thank you a lot! I would really appreciate the "coding big games" video in the future.
Great video John!
Great video, you earned my sub :)
I would love to see the video on Even System. Can’t wait xD
Thats some top tier video. Straight to the point.
I will pray youtube algorithms for you my friend.
Thanks a lot for great video
This is insanely helpful! Thank you so much
That's why its best to use mixed lighting (baked on some areas & realtime on others)
One of my first unity projects was in URP and one of the first issues I ran into was placing more than 8 real-time point lights and they’d disable themselves kuz only 8 can be loaded at a time- that pushed me to learn about baked lighting and light probes. So fucking worth
mixed lighting means one light illumination works for baked lightmaps for static objects, realtime lighting for dynamic objects, and realtime shadows for all ( or shadowmask for static). it's no better than baked lighting workflow.
The pc/console game industry has ditched lightmaps (baked and mixed light in unity) for years,
So just use realtime gi workarounds.
Great video!
+1 for Event Systems.
There can never be enough videos about single-responsibility and modularity in development.
Please talk about how powerful event systems can work in different game types and how interdependencies can cause nightmares.
Great video. That ending make me chuckle hard lol.
Very pog content, I actually took notes for the first time lol, the video about coding for complex games would be great!
Super good video. Love the detailed advice!
The ending by listing your pateron error codes has me dead in my chair. LOL
Very well done video! Thank you for the tips!
"Writing code for a complex game" - yes please. Great video, would love to see more in-depth content from you.
Great vid, thanks for making it, learned a bunch. I think it'd be neat to see vids on the code/architecture side if you wanna make those.
Still working on it. The coding video will be a bit longer, so it will take more time to make it. ^^
I guess it goes without saying, but if you want to make a big complicated game, you need to be knowledgeable about game development, intelligent, and experienced. Too many inexperienced developers have big dreams of making big games that will be the next [insert open world game here].
I'm 36 now, and I've been doing this since I was about... 15. At this point in my life, I'm more than just a "jack of all trades, master of none," I know most aspects of game development on a deep level. I'm a jack of all trades and master of many of those trades. When I set out to make a big complicated game, the planning phase is monumentally important. I need to plan what the game looks like structurally before I place a single cube down in Unity. I need to have an idea of what the data will be structured like, I need to figure out if I'm going to use virtual texturing, HDRP, URP, how I'm going to pack my textures, what kind of audio fidelity is needed, what the art style needs to be to suit my aesthetic and performance desires, decide how modern the game will be and how that will affect how many people will be able to run it (will I be making a game with baked lighting? Am I making a very modern game that uses no baked lighting and uses ray tracing features exclusively? Is there a level of dynamism in the game that it even warrants real time lighting?)...
There's a lot to consider, and if you're only a couple years into game development you might not even be aware of what questions to ask and what to consider, let alone how to consider it.
As far as optimization, in my experience I've come to realize that rather than "don't optimize until you need to," time and experience will teach you what optimizations can be done in all kinds of situations, and you should carry those optimizations into EVERY project you do. Because if you optimize (and PLANNED!) your game all along, you won't have to after it's done which can lead to soul-crushing code refactors and bugs on the tail end of your development.
Not sure if you're aware of the full quote because of the way you used it sounded quite condescending, at least that's how I interpreted it. Here is the full quote though “A jack of all trades is a master of none, but oftentimes better than a master of one." I hope if you were unaware before you'll now be able to enlighten any ignorant person that tries to use that quote as an insult. Cheers!
I am 37, literally have been at this as long as you have. I am a 3D artist that now teaches coding at the university level. I completely agree
@@ikobi4807 More like delusional air blower XD
I once tried using pure raytracing in a game using ships made of components made 100% in OpenSCAD for a simple (well okay not really) Eve clone prototype, but with Nexus: TJI ship combat, with each ship having their own 100% virtual machine to run the ship. Not for the weak of cpu, but size was tiny for what I had. Even if cpu was no issue, it did not run very well and looked way too Fortnite, but the idea was solid.
Too much work though.
32 here, and I frankly disagree. I am a hobby programmer at best, doing the starts of an MMO here.
Knowledgeable about game development, sure. Intelligent, sure... Experienced? Nope... but it helps.
But all you really need is basic knowledge, know that you have to optimize, etc. and search up the rest.
A plan? Not really. You do need to know an overall goal you want to work towards, but even with huge games, you can still take it step by step. It just needs more prework than most other projects.
EDIT: Oh yeah, by pre-work, I more mean the optimization, step by step keeping the game together and not just solve problems at "some point".
I have very little experience with game development, but I do have some experience with other things such as web programming, and always have had an interest in complex systems and understanding game performance.
This was a very interesting video even though I don't really plan to make any sort of big game. It is very cool to learn that a lot of techniques are quite manual and rely on the developer to manually write them for the game. This is also reassuring and great to hear in case I do make my own games or even content for other games like VRChat which use Unity.
I always have wanted to dig through a performance profiler of many of the games I play to find possible performance improvements. Great video!
+1 for an event system, great video!
Lol the patreon list at the end killed me hahaha, good video man, keep them coming.
video was really great but it was totally overshadowed by the genius of the outro, keep it up
Yes please! I would love to see some videos about structuring performant code for large games...particularly the usage of ECS for batching groups of scenery into subscenes and using DOTS graphics.
I think that, for baked lighting and especially in the example you were showing, that you can split your game into rooms and bake those rooms. You could also create a scene dedicated to this room just to bake stuff or cheking and verifying how everything in this room plays. You could also, I think, develop the room on its own scene so that you can navigate in your environment. I think this particular point was brought up during the Editor Performance video chapter, but I think that adding the tip that you could bake lightings per room or divisions and only rely on realtime lightings on light sources that could span in multiple rooms or object groups.
I find the optimising part of a game as interesting as it is crucial. My current computer was made in 2014 and was an average gaming build at the time (meaning a good machine in the broader PC configs) but it's starting to feel less and less powerful for more recent games... especially with indie games.
It may seem weird that indie games are harder on the hardware than AA or AAA games. But I think that's even more logical. Big game studios theoretically have more budget to optimise. While indie studios aren't even aware of the performance issues, or do not care enough.
I have a will to make my games more accessible to more modest PC configurations, so optimisation is a very important topic to me. My computer can still handle gamedev because of the "extra mile" my friend invested into the CPU at the time.
To be honest, when I am downloading the one map demo of an indie game that in itself weighs 12+ GB, I internally suffer. One, because even if my download speed is good, I think that there are still many many gamers that have a less powerful bandwidth. Two, because I know that, even in lower graphic settings, it will most likely have performance issues and few optimisations to offer. It's a general feeling I have and it may be exagerated, but I feel like most of those indie demos would really deserve more optimisations.
Great advice! I'd love to get a more in-depth discussion about a central communication hub as suggested in your video.
I saved your video for future reference. Please make more videos on large-scale game development, these are hard to find.
Great video dude!
You made my day ... started to use an event system to pass paramaters from scene A to Scene B ... but giving a Unique ID its a way cleaner option!
Very interesting video. I'm not into unity and I surely never will, but I think that the overall concepts you've outlined here are also applicable to other engines like Unreal. Thank you!
Very well presented information and the Patreon bit at the end killed me haha
Amazing informative video. We'd like more info about this subject. Big open world games, RPG systems, stream loading, big terrains, scene loading etc. Thanks!
I'd also recommend looking into texture compression like crunch compression, especially for things like roughness/metalic maps (where you can also reduce the resolution) where the compression is less visible, or masks for special shaders. But generally crunch compression for everything but hero objects won't have an obvious visual reduction. And as a result can take a 10GB game down to like 1GB.
Also with URP and HDRP it's ideal to have as few shaders as possible.
This is a great video on this topic, and a lot of it applies to other game engines as well!
Good overview of potential problems with Unity development! Nice video. 🙂
Great video! Almost all of the tips are sort of a must have in any more or less normal project. Unless you are stamping trash mobile games every week - all of these tips are really useful.
Simple, accurate, appreciated. Thank you.
Really amazing video, I saved this to rewatch now and then. In my personal opinion, the lightmapper is soooooo time consuming. I've tried so much times to use it, and kinda get to know how to make it work, but honestly it's waay more easier to simply use realtime lighting, and it looks pretty similar. I guess it can be used only in level based games, like portal for example
Very amazing video. More pls)
Very dope and informative video!
That's really awsome, no one ever talk about large games, I literally learn many things and realize i was wrong about many things
First-time visitor and I love your intro.
Good tips , other things i would add are things like :
-caching , if you can cache somthing then fking do it , and if you can reuse an item then do it , i've seen a lot of codebases that had stuff (especially in ui code ) like "if something changed then destroy all UIs/objects and rebuild from scratch" , don't be lazy , react to changes accordingly instead of "rePaInT aLL" on every slight change
-speaking of UI , only make interactable the things that matter and disable "raycast target" and "maskable" on eveything by default , i actually made an editor script that does that automatically.
-if you can bake or precalculate something in editor or a loading screen then do it, try to take as much work off the game during runtime.
-if you are running into a bottleneck with stuff executed in update , try to avoid branching by using a jump table or reformatting the data in a way where you can put it i an array and index into it directly.
-if you can express logic with an array lookup , do it
- the more generic a solution , the more you account for stuff that you probably wont run into and will just be useless overhead , try to make your solutions as domain specific as possible
- if there's a task you can automate or make an editor for then do it , your futur self will help you.
-unity can be a really dumb engine that would rather give you a straight forward solution/answer but keep the performance overhead/consequences hidden , do the extra digging
.pooling
I can keep typing on and on but i am too tired rn , hope this helps tho
Good points, about the UI point, there is actually a way to change the default values of Unity components, so you could disable raycast target and maskable by default, without a custom script. Im at work so I can't open Unity right now, but the option is hidden somewhere in the player settings menu
@@r1pfake521 oh yeah I know that one, in my case I needed a script since i did extra checks like checking if i had a parent that had a mask component before toggling maskable on , or whenever i create a button the script automatically unticks all raycast targets on children and adds a single "collider" image under it called "Interactable" that recieve the ui callbacks
Good video, great points. For my first game I decided to go as big and ambitious as possible. Five years later and I've learned soo much but... still no game lol. I still feel like its just within reach and Unity has come such a long way. Anyways, I find that packaging game areas and sub areas into prefabs and instantiating them at runtime OnCollisionEnter has been the fastest way to build massive levels that run great. AI and Rigidbodies are another issue though. I also decided to include physical objects that can be moved around and put on vehicles, etc. Interesting problems to solve for sure.
Golden video. Share more experience on loading/unloading regions of big world please
I subscribed and am eagerly waiting for that video about writing code for a complex game
You deserve all the subs,
Thank you
Hey there! I rarely comment but I think you deserve one ;) Very good and interesting videos. What I love about it is , despite beeing about Unity, most of the advices works for all game engine. I'm trying to learn Godot , and depite it beeing a very good engine, it's also one that needs the devs to optimize their games a lot, especially if you are working on 3d games. And I knew some of the stuffs you talked about, but other were really helpful. Liked your videos and I do believe you really deserve it! Nice work!
Edit: Also, would totally love a detailed video about optimizing scripts :P
Thanks a lot for your comment :D
I'm looking forward to a Code Optimization video, but first I want to share the event system, as it's a very cool pattern (when used correctly). ^^
Wow man... Thank you very much for sharing.
I work full time for a small company doing mobile games, so i got a little bit of experience, but very little when it comes to PC games. Had already figured out i would have some of those problems, but thank you for you video. I'm going to develop the game systems using a terrain with 10% of the full size, but sooner or later, i'll have to upgrade my PC to continue. (btw, i'm using Polaris, which seems to be better than Unity's built in terrain)
What a great quality and informative video. This is coming from a beginner developer. Could you make a more detailed video on how to code a big game?
Subbed. I don't even use Unity but this is informative.
Subscribed to see that event system!
Veery informative and well made thank you!
great video, this is really helpful. Thank you
Thank you, helped a lot!
Thank you, this is very helpful!
Useful and two the point. Thank you.
Loved the video!
It is hard to find in youtube videos about actual production/commercial-quality projects. There is a lot of tutorial for beginners but not so much content for solving "real world" problems like these.
Hoping to watch more videos like this one.