IJobEntity - The NEW Way to Change Entity Data in ECS - Unity DOTS Tutorial [ECS Ver. 0.50]

  Рет қаралды 16,796

Turbo Makes Games

Turbo Makes Games

Күн бұрын

❗❗ Caution: This video was made with an older version of ECS. See pinned comment for further Details ❗❗
📌 Download the full project files: www.tmg.dev/IJobEntity 📌
👨‍💻 Code/Scripts from this video: www.tmg.dev/IJobEntity-Code 👨‍💻
💬 Come chat with other DOTS/ECS devs: tmg.dev/Discord 💬
🚧 Resources Mentioned 🚧
- How to Setup New ECS 0.50 Project - • How to Create a New Un...
- IJobEntityBatch Overview - • IJobEntityBatch - Unit...
💻 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 - IJobEntity
- 1:17 - Translation Project Overview
- 2:03 - Creating an IJobEntity Job
- 3:36 - Execute Method & Default Query
- 5:29 - Running the IJobEntity
- 7:03 - IJobEntity Scheduling Options
- 7:21 - IJobEntity with Specific Queries
- 10:20 - Modifying IJobEntity Jobs at Runtime
- 11:44 - Invalid Entity Queries
- 13:02 - Battle Arena Demo Overview
- 14:59 - Perform Spell IJobEntity
- 16:17 - Passing MonoBehaviour Data to ECS
- 17:00 - Creating and Scheduling the IJobEntity
- 18:22 - Final Demonstration
- 18:59 - Shoutout to the IJobEntity Devs!
🌐 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

Пікірлер: 63
@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: kzbin.info/www/bejne/f4CZkGmPlL6Imqc 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
@felixliao8314
@felixliao8314 2 жыл бұрын
Good stuff! Sounds like IJobEntity has the benefits of: 1. can pass in more than 8 components 2. can be reused in mutiple systems. 3. can execute on different entities based on the entity query input.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Yep, those are the main ones!!
@nomadshiba
@nomadshiba Жыл бұрын
also can run multiple times with different parameters
@smallflyDE
@smallflyDE Жыл бұрын
And looks much cleaner imo!
@DejaimeNeto
@DejaimeNeto 2 жыл бұрын
Good to see DOTS API finally catching up to other ECS engines and libraries, great stuff! Still ways to go though, but I'm also glad they're back talking about dots in general, that silence was awful.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Indeed! Hoping they keep this momentum up to 1.0 and beyond
@LukeAps
@LukeAps Жыл бұрын
Thanks for this Jonny. Sick and tired of dealing with the Entity.ForEach arg limit.
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Sure thing Luke! I've been switching some systems over to IJobEntity myself as well...
@KonradGM
@KonradGM 2 жыл бұрын
Continuing from my preivous comment, what i think would be very good is to have an updated 2022 crash course on unity ecs, what i mean by that is that avter going trough a lot of youyr videos i have quite an idea about how it owrks, how dots works etc... but at the same time ,there is a lot of outdated stuff, like you mentioned in someo ther videos ComponentSystem is Outdated and SystemBAse should be new norm, there are some little stuff like that here outside of that, big thank you for the vids, i believe you are te go to guy regarding ecs and dots un unity right now :D
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Yes, definitely overdue on something like that!!
@GoldenMoments100
@GoldenMoments100 Жыл бұрын
Love the Doug DeMuro reference :)
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Hehe shout out to Doug!!
@wlsmdltn
@wlsmdltn Жыл бұрын
SOOOO Usefulllllllllllllllll Tutorial. Thanks Turbo! Deep Thank you!
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Awesome - so glad to hear this! IJobEntity is a great feature 😀
@nomadshiba
@nomadshiba Жыл бұрын
this can be used if you wanna run the same Query job with different variables which is really cool, i can get rid of many copy paste code thanks to this
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Yes I've been doing this a bit and it has been working nicely 👍
@Songfugel
@Songfugel 2 жыл бұрын
Def. a huge step forward. Would like to see ECB to get a shorthand [tag] a bit similar to what query index got, to ease setting it up. Maybe something akin to [ECB] Ecb ecb; that will get autofilled like Serialized fields do I also wish there'd be premade ecb for start, mid and end of systems cycle, to which you could just easily queue up stuff during normal parallel queries, that will then patch run all queued up structural changes and deletes at a set safe timeslot that could be optimized to smitherines Consider them like upkeep,resolve damage and end of turn phases in games like magic the gathering where all the stacked up effects are resolved in patches, jt it really clear ups systems/ game mechanics design, if you already had these clearly defined systems you could (but wouldn't have to) use. Would especially help collaboration, when everyone isn't running their brand own custom system every time
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Yes, streamlining how ECBs are setup would be really great. Those all seem like great ideas, cheers!
@tbunreall
@tbunreall Жыл бұрын
Hi, I'm trying to convert my game to ecs after using unity for a year. Your channel seems to have the most up to date information, but it's found in a bunch of videos explaining the individual parts. This makes it hard for me at least to put all the pieces together. Could you make a video series on making a very basic game, so we can at least see how all the pieces of the puzzle come together? My game is too complex for me to understand how to convert it with just videos explaining the different components of ecs/dots
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Yes, I totally understand how valuable something like this will be - got some things in the works that will definitely help with this 👍
@jkRatbird
@jkRatbird Жыл бұрын
Saaaame! Been following this for a couple of years now, and it seems like the usability improved a lot by now! This code is SO much more readable then anything dots related back in 2019! Now I feel ready to jump in! Just need a good up-to-date entry point, and then we can look up things we need in your backlog as we go! Thanks for an amazing and criminally underrated channel!
@nosh247
@nosh247 2 жыл бұрын
hey Johnny excellent tutorials. I was wondering what ide you use for your code?
@daxodearchives9467
@daxodearchives9467 2 жыл бұрын
He uses Rider by JetBrains :D (it integrates really really well with Unity)
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Yes, JetBrains Rider - it costs a bit of money, but it is well worth the price many times over.
@lontis
@lontis 2 жыл бұрын
Hey Turbo and Danny IJobEntity looks good but is there any chance to let the job run for more than one frame? It seems a bit like wasted potential if not. You could run complex pathfinding or detailed terrain generation otherwise. Love the videos though. Your channel is one of the only 3 channels I log into youtube to watch anymore.
@lontis
@lontis 2 жыл бұрын
Now that I think about it...It would be good to see more videos on longer running jobs. I guess that that is something that is not well documented. Whats a good way to keep track of these jobs? etc.
@zoltanborbas9080
@zoltanborbas9080 2 жыл бұрын
@@lontis Indeed, I would love to see something like that, a longer running example. For example a bunch of auto turrets shooting at each other, no dmg, just firing volleys and picking new targets. An RTS setting no input just to see what is a structure of setting up a game loop looks like.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Right now the way Jobs work in ECS is that they have to be completed within the same frame they are scheduled. However, there are definitely other options for distributing work over time that I'd like to explore more on this channel. Glad to know you're interested in that!
@romansalnikov5079
@romansalnikov5079 2 жыл бұрын
Hello mate! I just watched 2017 year conference about ECS, specificaly Entitas. And it said that soon Unity will have its own ECS and there will be no need to learn all the different frameworks like LEO or Entitas. And then I remembered your videos. Please explain, DOTS is the ECS already developed by the Unity? Or is it easier to start with ECS frameworks like LEO or Entitas first?
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Hello! DOTS is Unity's Data Oriented Tech Stack and is a collection of packages that take advantage of Data Oriented Design and they have an ECS implementation as part of that. I have no experience with LEO or Entitas, but I think Unity ECS is at a good point right now where you can build out some things using DOD. All the best!
@Archimagus
@Archimagus 2 жыл бұрын
Does anyone else feel sad for the poor red capsule, always just sitting there, never getting to move? No, Just me? OK. Great video by the way, I haven't looked at dots in years as it's been such a mess, but it's really starting to look like something useable. I followed your "How to Create a New Unity DOTS/ECS Project in 2022 - Entities 0.50" video to get a project set up. What would you recommend for a good concise overview of how to get started using ecs/dots in 2022?
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Haha poor red capsule - it's like he burned out at the start of the race then just went AFK 😆 Great to hear that Unity ECS is starting to look like something more usable since the last time you looked into it. Right now, things are a bit scattered as far as an overview on development, most of the videos I did using the previous version, 0.17, are still relevant, but it's been a while since I've done a more complete overview - got some things in the works along those lines though
@rocksfire4390
@rocksfire4390 2 жыл бұрын
it's looking good, can't wait until entities goes into 2021+ versions. at least we get time to mess around with it i guess.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Indeed, hoping we get 2021 support soon!!
@KonradGM
@KonradGM 2 жыл бұрын
in that case can i use IJobEntity along : ComponentSystem? since all examples is see of IJobEntity are used with SystemBase, and looking at documentation they both derive from the same library? (im starting with ecs so all this is new to me lol)
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Hey no worries, welcome and glad you're getting into ECS! You should not be using the "ComponentSystem" class for system - or anything for that matter - it is an old API and will be depreciated soon. You should use SystemBase for all systems in your game. SystemBase has more features that ComponentSystem and is generally easier to work with. If you still have any ComponenSystems, you can just switch them over to SystemBase - though you may need to clean up a few errors here and there.
@codemonkeynorth7503
@codemonkeynorth7503 2 жыл бұрын
if the entities can change at runtime, how would you know that the query is invalid? does the query just return null and therefore you'd know not to run it?
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Great question - it's a bit counter-intuitive as you see I'm creating the query at the beginning, but the query actually gets executed each time the job is scheduled - so it will always have the most up to data set of entities. If no entities are returned, then the job simply doesn't iterate over any entities. Hope that helped, cheers!
@stuartmansur
@stuartmansur Жыл бұрын
Hey man how do you use shared component filters with IJobEntities?
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Great question! I don't know of a way you can specify it in the IJobEntity job struct itself (though I wouldn't be surprised if we see that in a future update) For now, you have to manually create an entity query and set the shared component filter on that entity query
@heroldduboa5383
@heroldduboa5383 2 жыл бұрын
This helped me a lot, but I encounter a warning, any idea what it is? "There is no defined ordering between fields in multiple declarations of partial struct 'jobName'. To specify an ordering, all instance fields must be in the same declaration"
@DanielKierkegaardAndersen
@DanielKierkegaardAndersen 2 жыл бұрын
This happens when other errors happen. Look for the other errors and that one should follow along :D
@datcong974
@datcong974 2 жыл бұрын
does dynamicbuffer work with this? i tried to add dynamicbuffer paremerter like in Entities.Foreach but there is some error complier.
@DanielKierkegaardAndersen
@DanielKierkegaardAndersen 2 жыл бұрын
Should work are you typing in partial struct SomeJob : IJobEntity { void Execute(ref DynamicBuffer elements){...} } ?
@LukeAps
@LukeAps Жыл бұрын
RE: MonoBehaviour talking to SystemBase scripts. To do this cleanly, ( I also used to do data on an entity ) you should use the Singleton pattern ( "public static ExampleSystem instance;" on the ExampleSystem ) OnAwake you set instance = this; and from there can access the instantiated system. Including ALL it's functions and scheduling jobs. In our game, I have it such that our Monobehaviours call functions such as "CommandSystem.ClearWorld( ENTITYTYPE.ALL )" that executes an Entities.Foreach ( or perhaps an IJobEntity! ) that then cleans up all the entities.
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Yeah that approach would definitely work as well! In fact you can make it even cleaner than that - as all systems are guaranteed to be singletons, you don't even have to do a "public static ExampleSystem instance;" yourself. From your MonoBehaviour (or any other system for that matter) just do World.DefaultGameObjectInjectionWorld.GetExistingSystem();
@LukeAps
@LukeAps Жыл бұрын
@@TurboMakesGames Ahhhh thank you!
@nomadshiba
@nomadshiba 2 жыл бұрын
idk why would i but i can also use this as IComponentData which is really cool just tried it
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
Yes you can! That was actually one thing I experiment with when passing data from the MonoBehaviour to ECS is by creating the IJobEntity in the MonoBehaviour and storing it in an IComponenData, but sadly it did not work
@mobysound3726
@mobysound3726 2 жыл бұрын
안녕하세요오~
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
👋👋
@thanatosor
@thanatosor 10 ай бұрын
IJobEntity ? I thought that belong to Apple career 😂
@TurboMakesGames
@TurboMakesGames 10 ай бұрын
Nicee 😁
@jesusmartinperegrina
@jesusmartinperegrina 2 жыл бұрын
Dude, this is just for translating a captsule in one direction? Now C++ and Unreal doesnt look so troublesome... XD
@kennethgriffin5761
@kennethgriffin5761 2 жыл бұрын
If that's all you got from this video then you should stay away from DOTS. Moving specific objects will of course be more complex in a not object-oriented tech stack.
@rocksfire4390
@rocksfire4390 2 жыл бұрын
Jesús Martín Peregrina it's actually translating a unlimited number of captsule's in a direction because the system works on any number entities. once a entity is created, it's added to any system it's components are apart of automatically. getting the framework up and running is more work but you actually save time doing it this way. plus you also get insane performance even though you are writing in C# and much easier use of multithreading.
@TurboMakesGames
@TurboMakesGames 2 жыл бұрын
The simple translation job is just an easy way to show how to setup the IJobEntity jobs - Will have plenty more videos with cool things you can do with them if you're interested
@djsUltra
@djsUltra Жыл бұрын
This is cool. Maybe I'll use it for jobs that need to be scheduled on multiple different places. Atm I'm just calling methods on my systems which use entities.foreach but it seems a bit hacky.
@TurboMakesGames
@TurboMakesGames Жыл бұрын
Yeah that seems like a good use case for IJobEntity. It definitely is nice being able to call it from multiple places 👍
@Heisenberg-xc8ub
@Heisenberg-xc8ub Жыл бұрын
The TempGenerated code causes Unity to detect duplicate classes. Any tips for that? Error is Temp\GeneratedCode\Assembly-CSharp\MoveSystem__JobEntity_375329545.g.cs(14,14): error CS0101: The namespace '' already contains a definition for 'MoveSystem' I already checked and I don't have other MoveSystems
@Heisenberg-xc8ub
@Heisenberg-xc8ub Жыл бұрын
Found it, was missing the partial keyword
@TurboMakesGames
@TurboMakesGames Жыл бұрын
@@Heisenberg-xc8ub Nice, glad to hear you figured it out!!
Should You Use DOTS in 2024? (plus what is Unity ECS)
30:15
Turbo Makes Games
Рет қаралды 34 М.
1🥺🎉 #thankyou
00:29
はじめしゃちょー(hajime)
Рет қаралды 65 МЛН
Glow Stick Secret 😱 #shorts
00:37
Mr DegrEE
Рет қаралды 144 МЛН
Why? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 46 МЛН
Data-Oriented Input in Unity ECS - DOTS + Input System 2023
19:24
Turbo Makes Games
Рет қаралды 13 М.
How to Use SYSTEMS in Unity ECS 1.0 - Unity DOTS Tutorial
23:54
Turbo Makes Games
Рет қаралды 16 М.
Chunks! Where Unity ECS Data is Stored - Unity DOTS 2022
9:27
Turbo Makes Games
Рет қаралды 4,9 М.
2 Ways to use UI with Unity ECS 1.0 - Unity DOTS Tutorial 2023
22:38
Turbo Makes Games
Рет қаралды 18 М.
Unity Job System - A Practical Code Example
13:50
Infallible Code
Рет қаралды 80 М.
1🥺🎉 #thankyou
00:29
はじめしゃちょー(hajime)
Рет қаралды 65 МЛН