Тёмный

How to Use SINGLETONS in Unity ECS - Unity DOTS Tutorial [ECS Ver. 0.17] 

Turbo Makes Games
Подписаться 26 тыс.
Просмотров 6 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 30   
@TurboMakesGames
@TurboMakesGames Год назад
❗❗ *Caution:* This video was made using an older version of Unity ECS. While the core concepts remain the same, some of the API and workflows have changed as of ECS version 1.0. I would recommend checking out my ECS 1.0 tutorial video for a good overview of the latest standards for Unity’s DOTS: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-IO6_6Y_YUdE.html Once again, the theory behind the concepts of this video are still relevant, however the API has changed. Stay tuned for further updated videos on this subject. Please let me know if you have any questions either here or in our Discord community: tmg.dev/Discord
@hansayasa52
@hansayasa52 11 месяцев назад
I have a couple of Questions? If we do not change values of spawncapsuldata then does we need to do setsingleton and does we still need to do getSingleton inside onUpdated and why? if our plane has a collider but plane is in the main scene then does capsule entities which we are spawning have rigidbodies, then does these entites do not stop on plane when they fall insted they pass through them but if we drag the plane inside subscene then phaysics started working
@TurboMakesGames
@TurboMakesGames 11 месяцев назад
Hello - good questions! The reason we need to do a "Set Singleton" operation is because the singleton component contains a "Random" type. I have another video on this channel going into more detail on the ECS Random type, but basically it generates a random number from an internal seed value, and each time a random number is generated that seed value needs to change so a new random number can be generated each time. Essentially us doing a Set Singleton operation will write that new seed value back to the Random type. Then we need to "Get Singleton" every frame to be sure we have the latest data for the Random seed value. As for the physics question - when a collider is in the main scene, it uses the default Unity physics engine and when a collider is in a subscene it will use the DOTS physics package. Colliders in each of these physics systems will only be allowed to collide with other colliders in the same physics system. Essentially yes, that means that a plane in the main scene will not stop colliders in the subscene from falling through. Hope that helps!!
@hansayasa52
@hansayasa52 11 месяцев назад
@@TurboMakesGames thanks
@alejolab
@alejolab 3 года назад
ECS is really different to OOP, I feel dizzy just by watching this video @_@
@TurboMakesGames
@TurboMakesGames 3 года назад
Hah! once you experiment with it for a bit and learn to think in a data oriented manner, it begins to flow a bit more 😊
@shineking9450
@shineking9450 Год назад
hey i want to see the auto generated english subscription of this video like others. could you setting this for me?
@justinwhite2725
@justinwhite2725 3 года назад
0:55 now I'm craving tic tacs.
@TurboMakesGames
@TurboMakesGames 3 года назад
😁😂😂 Riiiiight!?!?
@mrbinggrae5954
@mrbinggrae5954 2 года назад
I need subtitles..
@TurboMakesGames
@TurboMakesGames 2 года назад
I have no idea why the subtitles are unavailable on this video, must be a thing on RU-vid's end, sorry for the troubles
@michaelbabcock6997
@michaelbabcock6997 3 года назад
Is the SpawnCapsuleData data component a separate script or a built in ECS variable? If so, can you start including all scripts that are a part of what you are doing? These videos helpful but I am trying to add to what I learned off other videos where I establish a struct that derives from :IComponentData. From those tutorials they make it very clear, but with this I am unsure of where the SpawnCapsuleData is coming from.
@mosth8ed
@mosth8ed 3 года назад
Yeah, it would definitely help to actually show SpawnCapsuleData. If no one knows what it is, it's hard to know how to emulate this in ones own work.
@TurboMakesGames
@TurboMakesGames 3 года назад
Yes, SpawnCapsuleData is an IComponentData I created. And I do include all relevant project files and code from my tutorial videos in the description! The first link gets you all the project files and the second one is a link to a GitHub gist page with all relevant code. Hope that helps you understand how this is all working 😊
@mosth8ed
@mosth8ed 3 года назад
@@TurboMakesGames Well then.. I almost always look there first to see if there are files, but for some reason I didn't this time. I guess that is on me, lol.
@gaidzin2
@gaidzin2 2 года назад
Спасибо, братан.
@TurboMakesGames
@TurboMakesGames 2 года назад
🙌🙌🙌
@Jennalcn
@Jennalcn Год назад
Is this method working only in one single system? Is there a singleton Component that can be get/set cross multiple systems?
@TurboMakesGames
@TurboMakesGames Год назад
That's the great thing about ECS - it is a separation of data from systems. So the singleton component can be accessed and modified from any system
@saito853
@saito853 3 года назад
Pretty surprised to know that they actually developed an API for Singleton specifically since it's such highly disregarded pattern in high level programming. What exact real-world use case would you recommend for this? I'm thinking of using this for global systems such as a day-night cycle, do you think it'd work?
@joepeters8746
@joepeters8746 3 года назад
All kind of Gamemanagers for storing global Variables or to control the flow are suited to get implemented with Singletons, in my opinion
@TurboMakesGames
@TurboMakesGames 3 года назад
Although it is highly disregarded in high level programming, there is no denying its usefulness in game development - sure there are alternatives but it is still widely used in game development. Funny that you bring up a day-night cycle as a real world use case - Unity released some ECS best practice guides and the example they give for the singleton pattern is a system that runs alongside a day-night cycle. In their example, during the daytime all sunflower entities point towards the sun as it moves across the sky during the day and at night the system does not run as there is no sun to point at.
@BoredDan7
@BoredDan7 3 года назад
Firstly the singletons in ECS are not really singletons in the traditional sense. ECS is not Object Oriented, a singleton in ECS is data that we ensure there is only one instance of within the context of the world. A singleton in OOP however is a class which ensure there is only one instance of in the entire program. A true singleton is global, and ECS singleton however is scoped to a world. Singleton is a bit of a misnomer here, really these are world state data.
@robertmoran4067
@robertmoran4067 3 года назад
@@TurboMakesGames Question - How is the singleton entity created, and what prevents multiple singleton entities from being created? Also where are the ECS best practice guides published?
@saito853
@saito853 3 года назад
@@TurboMakesGames Thanks for replying and yep that was exactly my thoughts. I'm working on an ecosystem for a DOTS game and my ideas are animals behaving differently depending on the day/night cycle. I'm gonna look up this best practices article later.
Далее
Ко мне подкатил бармен
00:58
Просмотров 149 тыс.
Mastering Singletons in Unity ECS
45:10
Просмотров 594