Тёмный

Unity ECS Area Selection - RTS/City Builder - 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/ECSAreaSelection 📌
👨‍💻 Code/Scripts from this video: tmg.dev/ECSAreaSelection-Code 👨‍💻
1️⃣ ECS Single Unit Selection Tutorial: • Unity ECS: Click to Se... 1️⃣
💬 Come chat with other DOTS/ECS devs: tmg.dev/Discord 💬
🚧 Resources Mentioned 🚧
ECS Single Unit Selection Tutorial: • Unity ECS: Click to Se...
TheScreamingFedora RTS Area Selection: • Unity RTS - Box Select...
URP Shader Graph Decal: • Decals & Stickers in U...
DOTS Physics Trigger Events: • Collision and Trigger ...
Get Component Data from Entity: • Get Data from Other En...
Entity Command Buffers: • How to Use Entity Comm...
💻 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 - Unity ECS Area Unit Selection
- 2:00 - Area Unit Selection Theory
- 5:03 - Unity Project Setup
- 7:25 - Selection MonoBehaviour Helper Script
- 9:02 - Additions to Unit Selection System Script
- 10:29 - Detect When the Player is Dragging the Mouse
- 12:07 - Hiding the Selection Area After Selection
- 13:12 - Calculating Vertices of Selection Area
- 15:37 - Creating the Selection Area Mesh
- 19:20 - Overview of the Trigger Event Job
- 21:05 - Scheduling the Trigger Event Job
- 23:18 - Cleaning Up the Selection Area Mesh
- 25:55 - Final Demonstration and Wrap-up
🌐 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

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

 

7 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 35   
@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 UPDATE March 2022 - If you're using the Entities 0.50 and Physics 0.50 packages or newer, there is an extra component you need to add to the selection entity archetype for this to work. Be sure to add the typeof(PhysicsWorldIndex) to the selection archetype, otherwise the collider does not get spawned into the game world. You'll still see the entity in the entity hierarchy, but if you enable physics debugging, you will not see the collider present. Another thing you may want to try if you are still having issues (especially if you are upgrading from an older physics/entities version) is to upgrade the physics authoring components. There is an automated tool you can use which can be opened at Windows > DOTS > Physics > Upgrade Physics Data. I ran the tool with the "Upgrade Materials" selected and everything upgraded successfully.
@BrokenCowboyy
@BrokenCowboyy Год назад
Hello Turbo and thanks for your videos. In this tutorial you access the UnitSelectionSystem in the SelectionManager MonoBehaviour. Is it possible to convert this system to an ISystem and still access it from the mono ?
@JamesCarolan1993
@JamesCarolan1993 4 месяца назад
That was a lot to digest. 😂 I’m contemplating whether I even need physics to achieve this. Thanks for a the tutorial.
@TurboMakesGames
@TurboMakesGames 2 года назад
UPDATE March 2022 - If you're using the Entities 0.50 and Physics 0.50 packages or newer, there is an extra component you need to add to the selection entity archetype for this to work. Be sure to add the typeof(PhysicsWorldIndex) to the selection archetype, otherwise the collider does not get spawned into the game world. You'll still see the entity in the entity hierarchy, but if you enable physics debugging, you will not see the collider present. Another thing you may want to try if you are still having issues (especially if you are upgrading from an older physics/entities version) is to upgrade the physics authoring components. There is an automated tool you can use which can be opened at Windows > DOTS > Physics > Upgrade Physics Data. I ran the tool with the "Upgrade Materials" selected and everything upgraded successfully.
2 месяца назад
After adding typeof(PhysicsWorldIndex) it started spawning but still SelectionJob isn't triggered.
@falricthesleeping9717
@falricthesleeping9717 25 дней назад
this still applies to physics 1.2.1, and thank you for saving me from a 12 hour session of headbutting against the wall
@FullMe7alJacke7
@FullMe7alJacke7 Год назад
Such an underrated channel, awesome work!
@TurboMakesGames
@TurboMakesGames Год назад
Much appreciated, glad you've been enjoying!!
@TurboMakesGames
@TurboMakesGames 2 года назад
Hey everyone, hope you enjoyed this tutorial video and found it helpful! Let me know what other types of these longer more topical tutorials focused around particular game mechanics you'd like to see me create in Unity ECS. These types of videos take a bit longer to make (but are also a ton of fun) so I just want to make sure I'm making tutorials that you all would find valuable. Cheers and keep on creating!
@tanukiinkognito3520
@tanukiinkognito3520 2 года назад
This was a great one, thanks!
@TurboMakesGames
@TurboMakesGames 2 года назад
Glad you enjoyed it, thanks 😀
@br0berson
@br0berson 2 года назад
You should mention that the project requires ProBuilder - without it, there's a missing component on the ground plane and the selected unit circles don't display in the game view. They do show up in the scene view, oddly enough. Thanks for the tutorial - ECS is like a completely different game engine and you're one of the few people out there focusing on how to get things done, rather than simply gushing about how great it is while never bothering to explain that it's utterly broken if you're not using the right outdated version of the Unity Editor. You're helping people make games they can ship and that's awesome.
@TurboMakesGames
@TurboMakesGames 2 года назад
Interesting as to why that's happening for you - the shader _should_ show up on the intersection of the invisible box and any mesh - doesn't even have to be an Entity mesh. Anyways glad to hear you've been finding the videos helpful, I'm having a ton of fun making them 😁
@falricthesleeping9717
@falricthesleeping9717 25 дней назад
So for anyone trying to do this in later versions (0.5,1.0 ...) the archetype needs another type PhysicsWorldIndex, yeah I know johnny commented the same thing, but just gonna comment this again since I just wasted 12 hours trying to understand why no triggerevents are not being processesd by the job
2 месяца назад
They all need a collider to choose with RayCast, but using Collider causes performance issues with huge amount of objects. I choose to go with WorldToScreenPoint method of Camera and checked parallel each selectable entity position on the screen if they're inside rectacngle that I draw with mouse. Without colliders, I can use 15k and more AI agents in the scene with 55-60fps
2 месяца назад
But you have to make sure your path finding algorithm provides avoiding agents each other, otherwise they'll overlap without colliders
@adventureswithles1772
@adventureswithles1772 2 года назад
First off thanks for all your hard work and putting these tutorials together. :) Running into a few issues that may be easy for you to help with 1) I tried downloading your project files, but it was a package 2) for the package to be imported I need a project :( I tried 3d project but then there was a lot missing like URP 3) figured that out but then needed to figure out how to get ECS etc added as packages, found your other video and that went mostly smoothly as the docs are changed for 2020.3.2 and the list of those packages are not there but figured it out 4) now I am stuck as the plane and SelectableEntity are pink and there are multiple errors of missing scripts one for plane and the material has a shader error. I have tried all the combinations but non seem to work. could you just zip up your project and put it on onedrive or and link it instead of a link to the packages? Thanks
@TurboMakesGames
@TurboMakesGames 2 года назад
Glad to hear you've been enjoying the videos! Thanks for the feedback, definitely want to look into a better way of delivering the project files to all you - usually I make all my tutorial videos in the same project so sharing the whole project will come with a bunch of extra stuff. That being said this project was done in a newer project with only a few tutorials in it. Here's the link to download the full project files - homecookedgames-my.sharepoint.com/:f:/g/personal/jthompson_tmg_dev/EmPwVifWF_NHrlHVuBYrWcABjkYT_qemB6X8AUKsQAzwbg?e=VNtLZ5 The subfolder under Assets you are looking for is "ECS_UnitSelection" (not the master one). Let me know if that works out for you!
@adventureswithles1772
@adventureswithles1772 2 года назад
@@TurboMakesGames 😀Thanks I will give it a try in tomorrow morning.
@rocksfire4390
@rocksfire4390 2 года назад
well done, this type of system is more robust because it doesn't matter what angle the camera is. that's pretty neat, however it does require physics which might or might not be ideal. i hope they show what changed in entities 0.50 soon, would hate for you to make something and it end up being outdated right away.
@TurboMakesGames
@TurboMakesGames 2 года назад
Thanks! Yeah I felt like this was pretty much the best solution I could come up with, with the tools I have available to me now.
@itsbarbaric
@itsbarbaric 2 месяца назад
For any future developers, there are always different approaches available, some take different routes but in certain cases can be much more performant. There were many iterations of the selection logic that I implemented, tested them on 1200+ entity count. But I found that collision can be still quite expensive even in ECS, though my approach did check collisions each frame (highlight option while dragging the rectangle) which turned out a bit more consuming that doing it only for the selection itself at the mouse release. Because of this I implemented frustum like approach, but without physics, using only render bounds and checking if its within the frustum of the selection rectangle GeometryUtility.TestPlanesAABB(planes, bounds).
@RockoShaw
@RockoShaw 2 года назад
Hello Turbo Makes Games. First of all thanks a lot for your videos and your efforts. I'm starting on Unity DOTS and I find your tutorials to be the best available as of today on the web. I wanted to ask if you have a tutorial or information regarding World Management? I would like to understand some basic stuff like creating a world, creating a new Entity, destroying an entity, moving entities from one World to Another, hiding and showing Entities on a World (I guess that depends on the renderer you are using). Because as of today I see we depend alot on accesing the Default world. Thanks a lot again
@TurboMakesGames
@TurboMakesGames 2 года назад
Hey there Oscar, glad to hear you've been finding the videos helpful! Unfortunately, I don't have any videos up on World management, I did some research into them a while back and the conclusion I came to was that they were needlessly complicated for most situations. Seems like the best use case for them was for multiplayer games where you could have client and server worlds. Just curious, what use cases did you have in mind for your project for manual world management? Good to know this is a topic you'd be interested in learning more about though!
@RockoShaw
@RockoShaw 2 года назад
@@TurboMakesGames Hello again, thanks a lot for your response. For example for scene management, I thought having different worlds would be an easier way to handle Scene switching. How do you deal with scene changes? What happens to Entities when you change a Scene, does every system get destroyed automatically? also, if you have multiple systems, how do you tell Unity to load Systems on specific scenes?
@TurboMakesGames
@TurboMakesGames 2 года назад
@@RockoShaw Yeah scene changing/management is a topic that I could probably do a few videos doing deep dives into. AFAIK right now, you'll have to destroy then recreate the entities in the different scene. Doing this of course would change all the index and version numbers on the entities, so you need to use something like the entity remap utility to update any entity references. As for Systems, you'll have to manually enable/disable them or use something like "RequireSingletonForUpdate" method. Again this does bring up some important topics that I'd like to explore further on this channel
@redforce8830
@redforce8830 2 года назад
This video helped me a lot in studying ECS. After watching this video, I checked the operation in the Perspective Camera well, but I confirmed that the operation in the Orthographic Camera (Not 2D Game) does not work the same. In Orthographic Camera, it seems that the creation coordinates of Vertices need to be different when creating ConvexCollider, but I am not sure how to do it. Can I get some help?
@redforce8830
@redforce8830 2 года назад
This question is about the behavior of the SelectMultipleUnits function.
@redforce8830
@redforce8830 2 года назад
I solved this issue, don't mind :)
@TurboMakesGames
@TurboMakesGames 2 года назад
Glad you figured it out!! For anyone else who comes across this, instead of making a pyramid from the camera, you'd just create a big box
@MAFIMA
@MAFIMA 2 года назад
asset files do not work
@TurboMakesGames
@TurboMakesGames 2 года назад
Sorry to hear that, I'm working on a better method of sharing project files with you all. For now I've put up the whole project here: homecookedgames-my.sharepoint.com/:f:/g/personal/jthompson_tmg_dev/El8eJwoofsxAlNjMzpBixJEBG4i5HV3F8BF4BDP8Y87gYQ?e=Q8O8rb The subfolder under Assets you are looking for is "ECS_UnitSelection" (not the master one). Let me know if that works out for you!
@GoodNewsJim
@GoodNewsJim 2 года назад
Yo Turbo. Can you look at this for a sec? I can't seem to simply ROTATE towards a position: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ZWN8YCCSfLM.html I spent 2 hours straightup trying to figure why my Xwing vs Tiefighter lead target code was messed up... Turns out the part not working was straight looking at a point... I think it has something to do with the weird rotation EULER translation space of ECS/DOTS
@TurboMakesGames
@TurboMakesGames 2 года назад
If you haven't already, check out the video I did on Transforms in Unity DOTS - setting the rotation doesn't "actually rotate" the entity until later in the frame when Unity takes the translation, rotation, and scale components then calculates and sets a LocalToWorld component, which represents the actual position, orientation, and scale of the entity. Hope that helps!
Далее
The tactic worked 😂#shorts by  Leisi Show
00:26
Просмотров 2,8 млн
меня не было еще год
08:33
Просмотров 2,5 млн
Should You Use DOTS in 2024? (plus what is Unity ECS)
30:15