Тёмный

Entity Queries in Unity ECS - Deep Dive into Finding Data - Unity DOTS Tutorial [ECS Ver. 0.17] 

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

❗❗ Caution: This video was made with an older version of ECS. See pinned comment for further Details ❗❗
📌 Download the full project files: tmg.dev/EntityQueries 📌
👨‍💻 Code/Scripts from this video: tmg.dev/EntityQueries-Code 👨‍💻
💬 Come chat with other DOTS/ECS devs: tmg.dev/Discord 💬
🚧 Resources Mentioned 🚧
ECS Singletons Video - • How to Use SINGLETONS ...
ECS Tags Video - • How to CORRECTLY Use T...
ECS SharedComponents Video - • How to Use Shared Comp...
ECS Change Filter Video - • How to Use Change Filt...
💻 My Game Development Setup: tmg.dev/GameDevPC 💻
📸 My Camera Gear: tmg.dev/CameraGear 📸
🎮 Let me know what other topics you want to learn about 🎮
⌚ Time stamps for key topics ⌚
- 0:00 - What Are Entity Queries?
- 1:17 - What Can We Do with Entity Queries?
- 2:51 - Queries in Entities.ForEach
- 6:25 - More Options for Entities.ForEach Queries
- 8:11 - Manually Making Entity Queries
- 10:57 - Entity Queries Outside of Systems
- 12:41 - Advanced Entity Queries
- 15:29 - Cool Entity Query Functions
🌐 Find Me Online! 🌐
📄 Blog: tmg.dev
👨‍💻 GitHub: github.com/JohnnyTurbo
🎮 Games: johnnyturbo.itch.io/
🦅 Twitter: / turbomakesgames
📺 Twitch: / turbomakesgames
🎵 Music by: Joakim Karud / joakimkarud
#️⃣ #UnityDOTS #UnityECS #MadeWithUnity

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

 

4 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 25   
@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
@odo432
@odo432 2 года назад
Just to expand on "ref" and "in" keywords. They are used because ECS works with structs which are value types (classes are reference types). Any time you pass a struct as a parameter or make a new variable of it, without using "ref" or "in", you are actually creating a copy of it. Any changes made to that copy won't affect the original reference. And every copy will consume space in memory. Technically, they are more efficient when used correctly and sparingly. However they can very quickly become highly inefficient if abused. "ref" and "in" in short just tells the compiler we want to work with a reference of a struct (treating it similarly to a class). "ref" means a reference to the struct with the ability to modify it. "in" means a reference to a struct without the ability to modify it. You could technically drop "in" and just pass the struct as a parameter creating a new copy of it (I don't think Unity allows this, I'm just using it as an example). This is technically faster and you won't risk modifying the original reference. However, once again you are working with a copy. If you have thousands of systems with thousands of entities you can see how quickly that will become a problem. The reason we use structs and not classes is because classes are objects which can only exist in memory (Slow) whereas structs can work on the the stack (Fast).
@r1pfake521
@r1pfake521 2 года назад
Why is creating and passing a copy (without ref or in) faster than passing by reference (with ref or in)? Shouldn't it be the other way around, because creating the copy itself takes additional time?
@odo432
@odo432 2 года назад
@@r1pfake521 Its because there's overhead involved when working with a reference. The compiler needs to point to the reference each and every time you want to access it or modify it. Whereas working with a copy you have direct access to the copy with no overhead. The problem with working with a copy is that it's technically an entirely new variable so any changes to it won't affect the reference. In order to modify the reference you need to set it equal to the copy. And because it's a new variable it takes up extra space in memory. This can have serious performance consequences if handled incorrectly. It's far more ideal to just use "ref" or "in" as it's super easy to abuse structs which can cause performance issues.
@LukeClemens
@LukeClemens 2 года назад
@@odo432 As a general rule for read only parameters, I'll use "in" if I want a read-only struct, especially if the struct is large to avoid copying it over and over for every update. For primitives like float, int, bool, etc, it's faster to just pass them without "in" and do the copy. I haven't determined which is faster for things like float3.... i mean technicallly passing a float3 requires copying 3 floats, whereas "in" only sets up a reference so there's no copy, but 3 floats vs 1 is pretty tiny and I'm not sure how much overhead comes with setting up a read-only ref via "in".
@TurboMakesGames
@TurboMakesGames 2 года назад
Thanks for the additional context, this is all very good information 👍
@TurboMakesGames
@TurboMakesGames 2 года назад
@@LukeClemens For things like float3 I think Burst might be doing some SIMD operations to improve efficiency
@steveimm
@steveimm 2 года назад
Awesome explanation, clears out many of my misconception cause I'm still new to ECS!
@TurboMakesGames
@TurboMakesGames 2 года назад
So glad to hear this, hope you're enjoying learning and experimenting 😀
@kerof4091
@kerof4091 2 года назад
Thanks for the incredible content
@TurboMakesGames
@TurboMakesGames 2 года назад
Thanks for watching - glad you've been enjoying 😀
@UltramarineAfterglow
@UltramarineAfterglow 2 года назад
Solid info. Now i will conquer the Universe with these powers...
@TurboMakesGames
@TurboMakesGames 2 года назад
All the best! (so long as you are a benevolent dictator)
@gabrielo4635
@gabrielo4635 2 года назад
I've been following along with your ECS series and hit at a roadblock: in your example, if you'd wanted to reference different groups of soldiers, how would you go about tagging them, then querying each group? I've watched your video on SharedDataComponent and it seems like the closest solution, but doesn't actually work with queries.
@TurboMakesGames
@TurboMakesGames 2 года назад
I'd agree that Shared Components seem like a good solution for what you are trying to do - I believe in that video I showed how to Query for them in an Entities.ForEach function (using the .WithSharedComponentFilter option) But for entity queries - you just need to use the EntityQuery.SetSharedComponentFilter method, passing in the shared component with values you want to query for. Hope that helps, but doing this specifically might make a good, quick follow-on video
@user-rb4bl6id9g
@user-rb4bl6id9g 5 месяцев назад
Далее
Final Update for Free Splined Mesh Tool | UE5 + UE4
16:49
Unity DOTS vs Assembly Benchmark - Which is fastest?
30:34