Here's a really great Unity feature you might now know about, build massive worlds! 🌐 Have you found the video Helpful and Valuable? ❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php
Hi, I have all the characters in the RTS game controlled by one script (for optimization), please tell me is it possible to use hybrid render for their rendering and physics? Without ECS
@@Gmania999 The Hybrid Renderer is a renderer that works with ECS components so you can't really use it without ECS. You can manually draw a Mesh with Graphics.DrawMesh();
As always, delivering cutting edge DOTS insight. Very helpful and never stops amazing me how well you break these complex topics down into biteable chunks!
I would love to see how you break up a 3d continuous world with subscenes and also once your world gets bigenough how the editor window performance is effected and can be improved. Another aspect with 3d worlds would be how do you deal with distant but visable objects that are visible from multiple subscenes away (consider a tower in or mountain in the distance)
You could use multiple LOD levels of subscenes, so like layer bigger subscenes, holding towers and big things, and smaller subscenes, holding trees, then grass, etc...
Also helpful would be how to build a full size spherical (or geodesic polyhedra) planet without crashing the editor. There is a bit of a catch 22 with needing it cut up before making it. Looks like it would need to be done in stages with math & not just plopped in...
First of all your typing speed and accuracy sounds like a stampede of little keyboard construction workers and I love it! Secondly, thanks for another great source of information about Unity features that are somewhat buried behind a competence barrier. I refer constantly to the official unity script API page and would never have found this info considering the way I browse it. I've been looking for a mechanism to increase performance on a single-scene game I'm building with a huge number of unique one-off meshes and materials, and I think this will be key to the solution. Thirdly, I continue to find it amazing how your videos make me feel smart and also stupid at the same time! This is great for helping me get an objective sense of my capabilities as a game dev, and I appreciate the opportunity to see how pro-level development is approached. Once again, the Unity community has shown that it follows an unspoken credo of helpfulness, unlike many other programming niches where the professionals and wizards treat the newcomers like worthless scum. CM, you make me feel included and respected.
You're basically my dictionary for when I'm watching more advanced dots concept videos and someone says something I don't understand (like subscene, for example). Fantastic channel, man.
This is exactly what I thought of doing when I heard of subscenes when they were originally announced. Just got back into messing with unity and was going to toy with this. Great that you have something up on it.
WOW this is so helpful! Thank you! I can't wait finishing my bachelor thesis. I'll totally get either into your patreon or get the bundle this summer and start making small game projects. Your tutorials are such great entry points into larger systems. This is gold!
There is so many possibilities that this can be useful for besides extremely Thing of a game that has a very complex UI with multiple windows or sections, those could all be saved in to a Subscene and loaded and unloaded as needed
Subscenes, LOD, repeating texture render on multiple objects and Occlusion Culling. Ah there's so many built in easy performance improving features it's sad how few use this to make huge games
@@magnusm4 The reason why not many are using it yet is because the DOTS packages are still in preview and aren't ready yet for production, but yes I do agree there is a lot of things in there than can help with 2D and 3D to greatly increase performance
Thanks always for your great work and ispiration. I reimplemented your example using Unity 2022.3 with Entity 1.0 and compare with MonoBehavior SceneManager.LoadSceneAsync. I create a demo Scene with 10000 SpriteRenderers. ECS -> SceneSystem.LoadSceneAsync has a very huge peak (FPS drop) at the really begin and it takes 37 frames to load the Subscene Mono -> SceneManager.LoadSceneAsync does not have any huge peak at the start and it takes 21 frames to load the scene (LoadSceneMode.Additive) During scene async loading they both have a similar fps It would be interesting if you create similar tests, to compare these two worlds (Mono and ECS). I guess with your experience you can create more reliable test results than mine.
wonderful, video, as always, details that make a difference, but I doubt, how would join sub scenes with path finding?. It would be a great video, that you could show how to make that union. Very good video, thanks for your time and dedication.
You didnt mention much about the LOD system with subscenes, but are these essentially just a substitute subscene if a subscene is very far away? Sounds like it could be faster than just relying on LOD gameobjects in a single subscene , but not a huge difference unless you have thousands of objects in your subscene
New to Unity, have been watching you videos and they have really helped me out a lot, thank you! Quick but possibly stupid question, would using prefabs in subscenes still propagate changes like they do if they weren't in a subscene? For example, if you wanted to change the color of the grass would you just change the prefab or would you have to "unpack" all the subscenes, change the prefab, then "repack" them?
This is a great video and I can't wait to give it a try. One thing I've noticed on this and the Prefab video is you are making Systems instead of Jobs for some of these systems. While I haven't tried this particular one out yet, shouldn't a "SceneJob" work fine to handle all of this or would it not worth with the Burst Compiler? Similarly I've found that spawning a prefab in a Job with DOTS also doesn't work with the Burst Compiler which is frustrating, if I want a Player to fire a Projectile Entity (something that would be incredibly common in a game), not being able to do that in a worker thread seems to be a problem. That, or am I missing something? (I really hope I am).
Not every system has to contain a job. Systems such as movement or turning on or off a single entity would run so quickly that it's actually better not to set such up as a job because it would just lead to you as the developer needing to write more code.
@@iCeDrAgOn2025 The new JobComponentSystem in the latest preview is the same amount of code as a ComponentSystem and it'll use Burst Compile by default. You'd think for consistency you'd just use the same one all the time if possible. I do think Systems are a bit easier by default since it doesn't require using Buffers, but it'd be nice for the future of DOTS if there'd be a consistent way to do it.
Normally I use the ComponentSystem when its something very simple like here just moving a single Player but yes ideally in a proper game you would make Jobs for everything. I believe the plan is to merge ComponentSystem and JobComponentSystem into one so in the future it'll be very easy to convert them. There is a small overhead when creating the job and their goal is to bring that down as much as possible. In terms of spawning prefabs you can do it with Burst but you don't do it with EntityManager.Instantiate(); You do it with a EntityCommandBuffer.Concurrent
@@CodeMonkeyUnity I definitely understand that for input, since Job or otherwise, it'll pretty tiny, it's not like movement, rotation or pathfinding which might influence 10s of thousands of entities (depending on your game of course). I should probably stop worrying around a tenth of a millisecond here or there with small Systems and Jobs. ;) Keep up the good work, I find these videos incredibly helpful.
Cool concept. It seems a lot cleaner than having scenes that are only whole if you remember to load in it's sibling scenes. And I never even thought of doing LOD's for entire scenes. I feel like you should have left a disclaimer when you just cycled through the whole sub-scene array to find the closest ones. That is bound to get slow when you have hundreds of these things. Its a weird problem to solve in code. So I think I would add a collider to each sub-scene and put them on a "sub-scene" physics layer. Then do a sphere cast with a layer mask for the sub-scene layer, from the player's position to find which ones are close. Sort of like a radar.
tbh the thing that I'm amazed about in this video ... I didn't think unity's DOTS worked with its physics. But if you can convert a subscene to Entities, then I imagine all the colliders, meshes, etc all still function. And I thought the problem with DOTS right now was that we didn't have access to physics with it? Guess I'm gonna have to do some research
Very useful and very cool, thank you so much for the tutorial, but I have a question, can this system be used with the grid based map unity system? If so, a tutorial on that will be awesome.
Hmm used with the Grid System how? I guess you could make a subscene and store it in each grid position but that's what's already being done here so no need for the Grid System in this case.
This is awesome! I haven't looked into SubScenes and your video is the first time I heard of SubScenes, I have been waiting for DOTS to mature before I rewrite the game engine for YAARRGH! Correct me if I am wrong and what I can tell after watching your video, I could replace my cached queue LIFO Chunk Manager with SubScenes? With your experience using SubScenes and its seems plausible, to have multiple SubScenes of about 10x10x10 size for a 3D procedural world? This is why I am loving DOTS, been working with DOTS for about a year, it is awesome and now with SubScenes, if it can do chunk management, procedural worlds will be amazing!
The one thing that I'm still not entirely sure about is if you can create or modify subscenes in runtime so I don't know how they would work for a procedural world. I'm guessing it should be possible since it does seem perfect for that use case but still need to research that.
@@alcofribasnasier1838 I know and I've done that myself. The question was do subscenes fix the floating origin problem. Also congrats on 50 lines of code, but I doubt that works for larger projects.
another great video! thank you very much! Going on from this. How would you add components to the entities in your subscene? What would be a proper way to identify entities in the subscene so you can add components correctly?
@@CodeMonkeyUnity thank you! My Problem was that I hadnt known I can just add IConvertGameObjectToEntity to the subscene gameObjects. there I can add all the tags and whatever I need.
How would you create subscenes to make procedurally generated content? it seems you have to have a subscene created before you start a game, but there is no way to duplicate scenes. So there's really not a way to use this to make infinite worlds...
As a theoretical, can you still have interactions in unloaded subscenes? Say you have a NPC chopping a tree down in an unloaded scene, can it make a sound? ;P But seriously, if there is a dynamic system in an unloaded subscence, can you still have its effects spill into loaded scenes? (Ex. A dam is set to blow on a timer and flood a region, but no one is around to see it, can other regions down river get flooded anyway?)
I'm an idiot, so you should probably wait for a comment from someone who knows anything. But I would imagine that it wouldn't be possible to have stuff happen in unloaded scenes (they are unloaded, after all). My (stupid) solution would be to use some kind of a trigger to make the thing happen anyway (you can use whatever system to load the scene to make the flood happen). For example game time? As in "after the game has been going for 50minutes, load the scene with the dam and destroy the town, then unload the scene until the player comes near".
@@washynator That's certainly one way for that sort of thing; but I'm thinking about dealing with massive dynamic environments where things can happen even without player involvement. Maybe something like another 'subscene layer' like how there can be a 'low render' and 'high render' scene depending on distance; there could be a 'data layer' which needs what's in the environment, but not any of the visual components (meshs/partical effects). Really just thoughts that came to me while watching the video.
Unloaded Subscenes don't really exist, if you look in the Entity Debugger the entities don't exist. I'm not sure if you can modify SubScenes after they've been converted, I believe they are meant more for the static parts of your game, so in your case you could use it for the terrain and whatever trees and rocks that never move but the dam and the water would be in normal entities on in a subcene that is never unloaded.
@@CodeMonkeyUnity So anything that is unloaded as a part of the subscene can't hold any state or persist and do it's own thing due to it not existing makes sense
You should do what terraria does to subscenesyou have a timer always running and when a subscene is loaded it grabs your timer and do some time checks to decide what is the current state of the sub scene
Just as I needed it, great! One question though; How to handle dynamic objects like enemies? They can't be loaded/unloaded based on the subscene, because they could follow the player for example. And what, if I want to save the state of an object, before it gets unloaded, so when I go back later, the object remains like the player left it? I will surely implement this, but this could be content for some of your next videos =) Keep up those awesome videos! (yea, that were 2 questions ^-^)
SubScenes are only meant for either static entities or entities where the state doesn't matter (like a flock of birds) so if you want some sort of state to persist then don't unload it through a SubScene. As soon as you load it loads from the data on the binary file regardless of what changes you made while the SubScene was loaded.
I've thought of using this for large open world games. Like GTA. Though I wonder, what stops you from making an entire game like this instead of using actual scenes, like making Half Life entirely into subscenes to remove the loading in between? Imagine making the entire summer camp in Psychonauts into one single map using this method. Thing go on in the background far away but the objects's functions are inactive and are basically in a passive mode that simply makes them move. Or having a massive building surrounded by a smaller base with a circle of water to a whole city. And you can see everything moving and being alive and go there. As I said, passively active to give the illusion of everything being one scene.
There's nothing stopping you, that's exactly how massive games like Skyrim are made. The world gets loaded in and out as the player moves around. It can become very complex though which is why a lot of games use the typical level structure.
@@CodeMonkeyUnity That and open worlds means typical optimization methods don't work like disabling objects obstructed by view. Even if they're far away, it's still a whole open plane of objects you'l have to low poly render and the sheer number alone can cause trouble even with less than 300 polygons. Then the engine itself can be limited. Like with Cursed Halo he explains there's a vertice limit of about 20 000 or more. This means regardless of your optimization you're automatically constricted by the engine unless you do like some developers and either modify the engine, or make a third party software to allow more to be rendered without lag or crashing.
Hi Code Monkey, Thanks for great (as usual) tutorial! I have one question for you - how do you handle obstacle collisions and movement constraints with ECS? Let's say we have one character controlled with WASD movement. What is the best way to constrain it so player wouldn't be able to move through objects? In legacy unity we have CharacterController script, but how we can achieve it in ECS? Is using DOTS Physics lib is good for it? Let me know what you think...
As always great video. Could you answer is it possible to save subscene like prefab and use it for instantiating in further? And how could we process some managed object inside subscene, like npc? Will they unload with the subscene and won't being processing? or maybe is there some work around?
When the Subscene is unloaded the objects are destroyed. But you could keep the logic of the NPC in another Entity that is outside the subscene and only have the visual inside the subscene and when that is loaded you look up the current state of the logic Entity to display the visual.
Hi, Awesome stuff as always, I really like your tutorials on DOTS with unity. I was wondering, in this vidéo you create a variable of class :"SceneSystem" and I can't seem to access it, am I missing a package or something? Take care and I can't wait for your next video.
@@CodeMonkeyUnity Thanks for your answer :D, I'm implementing Unity.Scenes, but it seams like there is no system called SceneSystem. I have access to something called SubSceneStreamingSystem but then there is no function called loadSceneAsync or anything alike.
Maybe a stupid question, but say an enemey is supposed to patrol 3 different subscenes, how can we ensure the patrol actually happens when we unload one or multiple of the subscenes?
Yup, from what I know the goal is to eventually have everything inside SubScenes so you won't even need to use the ConvertToEntity Script However there are still a handful of things that don't work as Entities like the Camera and the UI so for now those have to stay in normal game objects and everything else can be inside a SubScene
How does lightmaps work with subscene? Let's say you have one big world with 100 subscenes, I intended to bake the lighting. It is something that just works or will I be facing many bumps along the road? Also, same question but regarding baking occlusion.
Is it possible to add entities to Subscene in runtime or generate new Subscene with some entities? For example for procedurally generated terrain in ECS?
@@CodeMonkeyUnity Looking for the same, it'd be great for procedural work. I don't see any methods for it in Unity.Scenes, but I might miss something with my limited understanding of it all, docs.unity3d.com/Packages/com.unity.entities@0.5/api/Unity.Scenes.html
3:49 when I right-click in Unity v2020.1.6f1, I don't have the option to "create subscene" at the bottom of the dropdown menu. I just have 'properties' as the last menu item. Is there some setting I need to check or some package I need to install first? Do I need to buy Unity Pro version? Is there another component I need to add somewhere? What's the missing information here?
You could use an external map save file to store booleans for each destructible object to mimic this? IDK how efficient it'd be, but it could be a great start I guess
how do I add a LOD system, my meshes are created at runtime but I don't know how to have the chunks change their mesh to a lower detail mesh if the camera is further. I know how to actually load the entire chunk but not the lower detail one is the problem!
Can subscenes be different sizes or must they remain in a grid of all the same size? Say there is a very large scene where the camera zooms out and you want to contain it all in one scene, but there are other surrounding ones that are much smaller. Would this have any long term problems? Assuming all of the subscenes along side the edge of the largest one still have the same length and there arent any gaps within the map.
Is it possible to create a new subscene from selection, and then close for editing at runtime? For example if you wanted to split a large existing scene into subscenes at the start of the game.
Hi, I have problem with sub scenes, in my game when I am activating subscene the models are loading but, colliders does not work, So I can go through with my character or any other physical object
Would it be possible to see a video on the day and night cycle for 3D games? Like some procedural skybox that uses a custom shader. I'm terrible when it comes to shaders..
@@bezoro-personal Yeah but it's way to basic looking. Wish there would be a way to add more details to the skybox. Like the moon and stars. Also if you want to have different settings, like completely couldy sky.
@@CodeMonkeyUnity Yeah I have looked at the Lost Crypt demo project, but unfortunately for 3D this method for the day and night cycle would not really work. :/
hi, how would this work if i had objects that the player would interact with such as trees that fade when player is behind or effects like particles which is not static. also dose the vector3.distance work if my player is normal object and compare to entity pos?
DOTS involves 3 things, Entities, Job System and Burst Compiler The Job System and Burst compiler are already production ready Entities is still in preview
@@CodeMonkeyUnity And sub scenes are part of entities, right? That would mean the sub scene workflow isn't production ready or am I wrong? Thanks for the answer btw
The entire Megacity demo has more than a million objects in total and several hundred thousand at the same time. DOTS is super fast because the memory is all set up in a very efficient way that makes it so the CPU can just sequentially process each Entity and doesnt have to jump around ua-cam.com/video/Z9-WkwdDoNY/v-deo.html
@@omerfarukbykl6097 I'm not sure about using ECS but yes AAA engines are massively optimized to the point that you can just look at COD:MW or BFV and see how gorgeous they look with all those effects. That is the power of a custom engine that is handcrafted to suit a specific game.
After adding another gameobject into subscene, all gameobjects are drawn in wrong place, but their colliders are on correct position. Do you know how to fix it?
Here's a really great Unity feature you might now know about, build massive worlds!
🌐 Have you found the video Helpful and Valuable?
❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php
Hi, I have all the characters in the RTS game controlled by one script (for optimization), please tell me is it possible to use hybrid render for their rendering and physics? Without ECS
@@Gmania999 The Hybrid Renderer is a renderer that works with ECS components so you can't really use it without ECS.
You can manually draw a Mesh with Graphics.DrawMesh();
I can not make a subscene, the option is greyed out, can anyone help please?
@@joepeters8746 you need to save your currently open scene first.
As always, delivering cutting edge DOTS insight. Very helpful and never stops amazing me how well you break these complex topics down into biteable chunks!
Thanks!
I would love to see how you break up a 3d continuous world with subscenes and also once your world gets bigenough how the editor window performance is effected and can be improved. Another aspect with 3d worlds would be how do you deal with distant but visable objects that are visible from multiple subscenes away (consider a tower in or mountain in the distance)
Its the same thing, but you render everything in in a line in front of the character and dont render anything in the back and sides of the character.
@@00xenobil00 culling and dynamically loading map chunks are not the same thing. You definitely can use both
You could use multiple LOD levels of subscenes, so like layer bigger subscenes, holding towers and big things, and smaller subscenes, holding trees, then grass, etc...
Also helpful would be how to build a full size spherical (or geodesic polyhedra) planet without crashing the editor. There is a bit of a catch 22 with needing it cut up before making it. Looks like it would need to be done in stages with math & not just plopped in...
Basically, some in editor dots terrain generation. Probably need to start as base shape before transformed into stuff & it's LODs.
First of all your typing speed and accuracy sounds like a stampede of little keyboard construction workers and I love it!
Secondly, thanks for another great source of information about Unity features that are somewhat buried behind a competence barrier. I refer constantly to the official unity script API page and would never have found this info considering the way I browse it. I've been looking for a mechanism to increase performance on a single-scene game I'm building with a huge number of unique one-off meshes and materials, and I think this will be key to the solution.
Thirdly, I continue to find it amazing how your videos make me feel smart and also stupid at the same time! This is great for helping me get an objective sense of my capabilities as a game dev, and I appreciate the opportunity to see how pro-level development is approached. Once again, the Unity community has shown that it follows an unspoken credo of helpfulness, unlike many other programming niches where the professionals and wizards treat the newcomers like worthless scum. CM, you make me feel included and respected.
That's great to hear! I'm glad the video helped you! Thanks!
You're basically my dictionary for when I'm watching more advanced dots concept videos and someone says something I don't understand (like subscene, for example). Fantastic channel, man.
This is exactly what I thought of doing when I heard of subscenes when they were originally announced. Just got back into messing with unity and was going to toy with this. Great that you have something up on it.
bro you deserve at least 1 million subscribers. Your videos are amazing man
Great video. Please do a video about Animations using DOTS. Either with new Unity.Animations or some other way. Keep up the great work!
WOW this is so helpful! Thank you!
I can't wait finishing my bachelor thesis. I'll totally get either into your patreon or get the bundle this summer and start making small game projects. Your tutorials are such great entry points into larger systems. This is gold!
That's awesome! Best of luck with your thesis!
There is so many possibilities that this can be useful for besides extremely Thing of a game that has a very complex UI with multiple windows or sections, those could all be saved in to a Subscene and loaded and unloaded as needed
Subscenes, LOD, repeating texture render on multiple objects and Occlusion Culling. Ah there's so many built in easy performance improving features it's sad how few use this to make huge games
@@magnusm4 The reason why not many are using it yet is because the DOTS packages are still in preview and aren't ready yet for production, but yes I do agree there is a lot of things in there than can help with 2D and 3D to greatly increase performance
You are the fastest typist I have ever seen on UA-cam.
He uses speed force 😂
Thanks always for your great work and ispiration.
I reimplemented your example using Unity 2022.3 with Entity 1.0 and compare with MonoBehavior SceneManager.LoadSceneAsync.
I create a demo Scene with 10000 SpriteRenderers.
ECS -> SceneSystem.LoadSceneAsync has a very huge peak (FPS drop) at the really begin and it takes 37 frames to load the Subscene
Mono -> SceneManager.LoadSceneAsync does not have any huge peak at the start and it takes 21 frames to load the scene (LoadSceneMode.Additive)
During scene async loading they both have a similar fps
It would be interesting if you create similar tests, to compare these two worlds (Mono and ECS). I guess with your experience you can create more reliable test results than mine.
This is amazing! Thank you from the bottom of my soul, we need such in-depth tutorials on various systems!
Thank you for this tutorial. I had no idea it was this simple
Only thing is you need to do your own format to track what's the next scene without hard coding it. But still useful
This really helped me! I look forward to apply this to my project! Thanks a lot!!
Wow! Great video! This is like Minecraft chunk loading system.
You just saved me so many overlap triggers lol
wonderful, video, as always, details that make a difference, but I doubt, how would join sub scenes with path finding?. It would be a great video, that you could show how to make that union. Very good video, thanks for your time and dedication.
Pathfinding for massive worlds is definitely a topic I'd like to cover
Thank you, I was looking for this kind of solution to my game
You didnt mention much about the LOD system with subscenes, but are these essentially just a substitute subscene if a subscene is very far away? Sounds like it could be faster than just relying on LOD gameobjects in a single subscene , but not a huge difference unless you have thousands of objects in your subscene
If you unload subscene, load fake LOD model in there
New to Unity, have been watching you videos and they have really helped me out a lot, thank you! Quick but possibly stupid question, would using prefabs in subscenes still propagate changes like they do if they weren't in a subscene? For example, if you wanted to change the color of the grass would you just change the prefab or would you have to "unpack" all the subscenes, change the prefab, then "repack" them?
looks great sir ! do you also have an example in 3d scenes ?
Can we do this with bolt? I want to try and make a big world and this seems like the best way.
I would like to ask you if you can actually do an in-depth tutorial on animations in ECS.
I haven't yet looked at DOTS animations but it's on my list
@@CodeMonkeyUnity Thanks, be sure to check your videos out!
OMG YOU ARE PURE GOLD.
This is a great video and I can't wait to give it a try.
One thing I've noticed on this and the Prefab video is you are making Systems instead of Jobs for some of these systems. While I haven't tried this particular one out yet, shouldn't a "SceneJob" work fine to handle all of this or would it not worth with the Burst Compiler?
Similarly I've found that spawning a prefab in a Job with DOTS also doesn't work with the Burst Compiler which is frustrating, if I want a Player to fire a Projectile Entity (something that would be incredibly common in a game), not being able to do that in a worker thread seems to be a problem.
That, or am I missing something? (I really hope I am).
Not every system has to contain a job. Systems such as movement or turning on or off a single entity would run so quickly that it's actually better not to set such up as a job because it would just lead to you as the developer needing to write more code.
@@iCeDrAgOn2025 The new JobComponentSystem in the latest preview is the same amount of code as a ComponentSystem and it'll use Burst Compile by default. You'd think for consistency you'd just use the same one all the time if possible. I do think Systems are a bit easier by default since it doesn't require using Buffers, but it'd be nice for the future of DOTS if there'd be a consistent way to do it.
@@andrewshandle I think creating a job has an overhead so for player interactions for a single character you're probably better off not using jobs?
Normally I use the ComponentSystem when its something very simple like here just moving a single Player but yes ideally in a proper game you would make Jobs for everything. I believe the plan is to merge ComponentSystem and JobComponentSystem into one so in the future it'll be very easy to convert them. There is a small overhead when creating the job and their goal is to bring that down as much as possible.
In terms of spawning prefabs you can do it with Burst but you don't do it with EntityManager.Instantiate(); You do it with a EntityCommandBuffer.Concurrent
@@CodeMonkeyUnity I definitely understand that for input, since Job or otherwise, it'll pretty tiny, it's not like movement, rotation or pathfinding which might influence 10s of thousands of entities (depending on your game of course).
I should probably stop worrying around a tenth of a millisecond here or there with small Systems and Jobs. ;)
Keep up the good work, I find these videos incredibly helpful.
Yep , there we go !
I don't know what I would do without your videos man! Thanks for the hard work, hope one day be able to support you on Patreon!
Cool concept. It seems a lot cleaner than having scenes that are only whole if you remember to load in it's sibling scenes. And I never even thought of doing LOD's for entire scenes.
I feel like you should have left a disclaimer when you just cycled through the whole sub-scene array to find the closest ones. That is bound to get slow when you have hundreds of these things. Its a weird problem to solve in code. So I think I would add a collider to each sub-scene and put them on a "sub-scene" physics layer. Then do a sphere cast with a layer mask for the sub-scene layer, from the player's position to find which ones are close. Sort of like a radar.
Sure if performance becomes an issue you could build some colliders or just simply test the distance only once per 5 seconds instead of every frame.
tbh the thing that I'm amazed about in this video ... I didn't think unity's DOTS worked with its physics. But if you can convert a subscene to Entities, then I imagine all the colliders, meshes, etc all still function. And I thought the problem with DOTS right now was that we didn't have access to physics with it?
Guess I'm gonna have to do some research
DOTS Physics has been in development for quite a while and is already very advanced, check it out ua-cam.com/video/B3SFWm9gkL8/v-deo.html
Amazing perfomance
for some reason the componentsystem namespace doesn't exist for me? What have I Done wrong?
Did you find any solution? Ecs updated so much times. So i have same errors.
Once again Code Monkey proves they are the best!!
Is this better performance for 3d or would unity addressables be better for 3d?
Would you consider doing an updated video now that 1.0 is out? The code in this video no longer works. Cheers.
Yup I definitely want to cover DOTS as soon as I have the time
@@CodeMonkeyUnity great, looking forward to it
Thank you so much for this particular tutorial, very useful indeed.
How the reserved memory gets with this implementation?
So you create the large world then split highlighted poritons into subscenes?
Thanks for the juicy upload once again! can't wait to learn more !!
Very useful and very cool, thank you so much for the tutorial, but I have a question, can this system be used with the grid based map unity system? If so, a tutorial on that will be awesome.
Hmm used with the Grid System how? I guess you could make a subscene and store it in each grid position but that's what's already being done here so no need for the Grid System in this case.
Im really thankful for all your video's. Thank You.
I like this tutorial. Thank you
iknow this video is little ...old.. but... this can solve Float Origin Problems too? if yes... how?
This is awesome! I haven't looked into SubScenes and your video is the first time I heard of SubScenes, I have been waiting for DOTS to mature before I rewrite the game engine for YAARRGH! Correct me if I am wrong and what I can tell after watching your video, I could replace my cached queue LIFO Chunk Manager with SubScenes? With your experience using SubScenes and its seems plausible, to have multiple SubScenes of about 10x10x10 size for a 3D procedural world? This is why I am loving DOTS, been working with DOTS for about a year, it is awesome and now with SubScenes, if it can do chunk management, procedural worlds will be amazing!
The one thing that I'm still not entirely sure about is if you can create or modify subscenes in runtime so I don't know how they would work for a procedural world.
I'm guessing it should be possible since it does seem perfect for that use case but still need to research that.
@@CodeMonkeyUnity Thanks mate, I will check it out later, hope it works out
That's a great tutorial, thank you!
Aren't infinite worlds still plagued by floating point precision issues? Or do subscenes fix this by default?
floating points can easily be fixed with a simple return to origin, and it doesn't take more than 50 lines of code to do it.
@@alcofribasnasier1838 I know and I've done that myself. The question was do subscenes fix the floating origin problem. Also congrats on 50 lines of code, but I doubt that works for larger projects.
another great video! thank you very much!
Going on from this.
How would you add components to the entities in your subscene? What would be a proper way to identify entities in the subscene so you can add components correctly?
Usually you can identify a certain entity by adding a empty tag component
@@CodeMonkeyUnity
thank you!
My Problem was that I hadnt known I can just add IConvertGameObjectToEntity to the subscene gameObjects.
there I can add all the tags and whatever I need.
How would you create subscenes to make procedurally generated content? it seems you have to have a subscene created before you start a game, but there is no way to duplicate scenes. So there's really not a way to use this to make infinite worlds...
As a theoretical, can you still have interactions in unloaded subscenes? Say you have a NPC chopping a tree down in an unloaded scene, can it make a sound? ;P
But seriously, if there is a dynamic system in an unloaded subscence, can you still have its effects spill into loaded scenes? (Ex. A dam is set to blow on a timer and flood a region, but no one is around to see it, can other regions down river get flooded anyway?)
I'm an idiot, so you should probably wait for a comment from someone who knows anything. But I would imagine that it wouldn't be possible to have stuff happen in unloaded scenes (they are unloaded, after all). My (stupid) solution would be to use some kind of a trigger to make the thing happen anyway (you can use whatever system to load the scene to make the flood happen). For example game time? As in "after the game has been going for 50minutes, load the scene with the dam and destroy the town, then unload the scene until the player comes near".
@@washynator That's certainly one way for that sort of thing; but I'm thinking about dealing with massive dynamic environments where things can happen even without player involvement.
Maybe something like another 'subscene layer' like how there can be a 'low render' and 'high render' scene depending on distance; there could be a 'data layer' which needs what's in the environment, but not any of the visual components (meshs/partical effects).
Really just thoughts that came to me while watching the video.
Unloaded Subscenes don't really exist, if you look in the Entity Debugger the entities don't exist.
I'm not sure if you can modify SubScenes after they've been converted, I believe they are meant more for the static parts of your game, so in your case you could use it for the terrain and whatever trees and rocks that never move but the dam and the water would be in normal entities on in a subcene that is never unloaded.
@@CodeMonkeyUnity So anything that is unloaded as a part of the subscene can't hold any state or persist and do it's own thing due to it not existing makes sense
You should do what terraria does to subscenesyou have a timer always running and when a subscene is loaded it grabs your timer and do some time checks to decide what is the current state of the sub scene
Just as I needed it, great! One question though; How to handle dynamic objects like enemies? They can't be loaded/unloaded based on the subscene, because they could follow the player for example. And what, if I want to save the state of an object, before it gets unloaded, so when I go back later, the object remains like the player left it? I will surely implement this, but this could be content for some of your next videos =) Keep up those awesome videos! (yea, that were 2 questions ^-^)
SubScenes are only meant for either static entities or entities where the state doesn't matter (like a flock of birds) so if you want some sort of state to persist then don't unload it through a SubScene. As soon as you load it loads from the data on the binary file regardless of what changes you made while the SubScene was loaded.
@@CodeMonkeyUnity Yup, that makes sense. Thanks.
I've thought of using this for large open world games. Like GTA.
Though I wonder, what stops you from making an entire game like this instead of using actual scenes, like making Half Life entirely into subscenes to remove the loading in between?
Imagine making the entire summer camp in Psychonauts into one single map using this method.
Thing go on in the background far away but the objects's functions are inactive and are basically in a passive mode that simply makes them move.
Or having a massive building surrounded by a smaller base with a circle of water to a whole city.
And you can see everything moving and being alive and go there. As I said, passively active to give the illusion of everything being one scene.
There's nothing stopping you, that's exactly how massive games like Skyrim are made.
The world gets loaded in and out as the player moves around.
It can become very complex though which is why a lot of games use the typical level structure.
@@CodeMonkeyUnity That and open worlds means typical optimization methods don't work like disabling objects obstructed by view. Even if they're far away, it's still a whole open plane of objects you'l have to low poly render and the sheer number alone can cause trouble even with less than 300 polygons.
Then the engine itself can be limited. Like with Cursed Halo he explains there's a vertice limit of about 20 000 or more. This means regardless of your optimization you're automatically constricted by the engine unless you do like some developers and either modify the engine, or make a third party software to allow more to be rendered without lag or crashing.
Hi Code Monkey,
Thanks for great (as usual) tutorial! I have one question for you - how do you handle obstacle collisions and movement constraints with ECS? Let's say we have one character controlled with WASD movement. What is the best way to constrain it so player wouldn't be able to move through objects?
In legacy unity we have CharacterController script, but how we can achieve it in ECS? Is using DOTS Physics lib is good for it?
Let me know what you think...
It would be possibile to create subscenes from sprites and tilemaps ? Maybe you should implement some sort of conversion to meshes, I guess
As always great video.
Could you answer is it possible to save subscene like prefab and use it for instantiating in further?
And how could we process some managed object inside subscene, like npc? Will they unload with the subscene and won't being processing? or maybe is there some work around?
When the Subscene is unloaded the objects are destroyed.
But you could keep the logic of the NPC in another Entity that is outside the subscene and only have the visual inside the subscene and when that is loaded you look up the current state of the logic Entity to display the visual.
@@CodeMonkeyUnity thank you for answering. but what about subscene like prefab? is there not some tricky with it?
Hi, Awesome stuff as always, I really like your tutorials on DOTS with unity. I was wondering, in this vidéo you create a variable of class :"SceneSystem" and I can't seem to access it, am I missing a package or something? Take care and I can't wait for your next video.
It's inside Unity.Scenes
@@CodeMonkeyUnity Thanks for your answer :D, I'm implementing Unity.Scenes, but it seams like there is no system called SceneSystem. I have access to something called SubSceneStreamingSystem but then there is no function called loadSceneAsync or anything alike.
does this work for 3d too?
Maybe a stupid question, but say an enemey is supposed to patrol 3 different subscenes, how can we ensure the patrol actually happens when we unload one or multiple of the subscenes?
can i use subscenes for each characters like the layers of subscenes you mentioned?
Hey CodeMoney Can I use triggers for this too? trigger enter and exit?
Do you still have to worry about the issues when you get far away from the origin using this method?
They should have implemented open/close subscene on right click context menu or with shortcut
I'm using Unity version 2019.4.25f1 and don't have that option. Why?
What is the difference between this and occlusing culling? The other seems more appealing and practical
This will unload the asset so they are not in the ram. With occlusion you don't render objects but they are still loaded and take up memory.
Do you think, is it a good idea to load a subscene with common game manager and canvas to similar scenes, such as levels?
Yup, from what I know the goal is to eventually have everything inside SubScenes so you won't even need to use the ConvertToEntity Script
However there are still a handful of things that don't work as Entities like the Camera and the UI so for now those have to stay in normal game objects and everything else can be inside a SubScene
How does lightmaps work with subscene? Let's say you have one big world with 100 subscenes, I intended to bake the lighting. It is something that just works or will I be facing many bumps along the road? Also, same question but regarding baking occlusion.
Been playing around with this. All works fine in the editor - but doesn't seem to work in a build :(
Is it possible to add entities to Subscene in runtime or generate new Subscene with some entities? For example for procedurally generated terrain in ECS?
I'm not sure, that's something I still have to research. I imagine it should be possible since that would be a perfect application of this system.
@@CodeMonkeyUnity Looking for the same, it'd be great for procedural work. I don't see any methods for it in Unity.Scenes, but I might miss something with my limited understanding of it all, docs.unity3d.com/Packages/com.unity.entities@0.5/api/Unity.Scenes.html
Unity demo looks better than Cyberpunk.
If changes are made to a subscene in run-time, are these changes persisted if you unload and load again?
how can be changed from distance to trigger with colliders?
So this is only for a static environment right?
how did you use the subscene
I entered Unity and if I drag a Scene inside my actual Scene it is not child of the first
how do you prefer to use subscenes in multiplayer?
3:49 when I right-click in Unity v2020.1.6f1, I don't have the option to "create subscene" at the bottom of the dropdown menu. I just have 'properties' as the last menu item.
Is there some setting I need to check or some package I need to install first? Do I need to buy Unity Pro version? Is there another component I need to add somewhere? What's the missing information here?
Do you have the Entities package installed? Haven't touched DOTS in quite a while so it's possible the menu changed.
Could the scenes be infinitly generated?
Would this work with Multiplayer? I have some ideas on how to use it but just wanted to make sure it's feasible.
know any way to dynamically create subscenes at runtime?
Is there a way to await subscene completely loaded?
So if I understand right. I could use SubScene to put a level into it? So I can load unload levels with it?
How would this work with basic multiplayer (lan or intenet via photon etc) with players far and near. each other.
Cool. Always. Keep it up!
Is it possible to interact with the subscene objects in the game? Like destructing objects, etc...
You can, but if you unload and then reload the subscene I believe they will all go back to their starting state.
You could use an external map save file to store booleans for each destructible object to mimic this? IDK how efficient it'd be, but it could be a great start I guess
Can you upgrade the package dependencies to 2019.4 LTS please?
As allways great vid !
Do this work on mobile and for 3d worlds?
how do I add a LOD system, my meshes are created at runtime but I don't know how to have the chunks change their mesh to a lower detail mesh if the camera is further. I know how to actually load the entire chunk but not the lower detail one is the problem!
Can subscenes be different sizes or must they remain in a grid of all the same size? Say there is a very large scene where the camera zooms out and you want to contain it all in one scene, but there are other surrounding ones that are much smaller. Would this have any long term problems? Assuming all of the subscenes along side the edge of the largest one still have the same length and there arent any gaps within the map.
can i implement the same on a unity terrain?
Is it possible to create a new subscene from selection, and then close for editing at runtime? For example if you wanted to split a large existing scene into subscenes at the start of the game.
What does it mean that GameObjects are converted to entities? What are the pros and cons?
What do entities have to do with subscenes?
Hi, I have problem with sub scenes, in my game when I am activating subscene the models are loading but, colliders does not work, So I can go through with my character or any other physical object
Would it be possible to see a video on the day and night cycle for 3D games? Like some procedural skybox that uses a custom shader. I'm terrible when it comes to shaders..
@@bezoro-personal Yeah but it's way to basic looking. Wish there would be a way to add more details to the skybox. Like the moon and stars. Also if you want to have different settings, like completely couldy sky.
Not sure about 3D games but the Lost Crypt demo has a gorgeous Day Night transition
@@CodeMonkeyUnity Yeah I have looked at the Lost Crypt demo project, but unfortunately for 3D this method for the day and night cycle would not really work. :/
Why do we need to convert player to entity?
hi, how would this work if i had objects that the player would interact with such as trees that fade when player is behind or effects like particles which is not static. also dose the vector3.distance work if my player is normal object and compare to entity pos?
10/10
Is it already possible (and save) to use that in production?
DOTS involves 3 things, Entities, Job System and Burst Compiler
The Job System and Burst compiler are already production ready
Entities is still in preview
@@CodeMonkeyUnity And sub scenes are part of entities, right? That would mean the sub scene workflow isn't production ready or am I wrong? Thanks for the answer btw
I heard things like " by using dots you can use 1m object with almost no performance loss" is that true? how is that happening?
The entire Megacity demo has more than a million objects in total and several hundred thousand at the same time.
DOTS is super fast because the memory is all set up in a very efficient way that makes it so the CPU can just sequentially process each Entity and doesnt have to jump around
ua-cam.com/video/Z9-WkwdDoNY/v-deo.html
@@CodeMonkeyUnity do other game engines have that? for example game engines that AAA game companies use. It might open a lot of door for them
@@omerfarukbykl6097 I'm not sure about using ECS but yes AAA engines are massively optimized to the point that you can just look at COD:MW or BFV and see how gorgeous they look with all those effects. That is the power of a custom engine that is handcrafted to suit a specific game.
After adding another gameobject into subscene, all gameobjects are drawn in wrong place, but their colliders are on correct position. Do you know how to fix it?
Very interesting stuff.