Data-Oriented Input in Unity ECS - DOTS + Input System 2023

Поділитися
Вставка
  • Опубліковано 29 тра 2024
  • 📌 Download the full project files: www.tmg.dev/ECS-InputSystem 📌
    👨‍💻 Code/Scripts from this video: www.tmg.dev/ECS-InputSystem-Code 👨‍💻
    💬 Come chat with other DOTS/ECS devs: tmg.dev/Discord 💬
    🚧 Resources Mentioned 🚧
    Input System Tutorials:
    • How to use Unity's Inp...
    • How to use NEW Input S...
    Should You Use DOTS in 2023? - • Should You Use DOTS in...
    UI in ECS 1.0 - • 2 Ways to use UI with ...
    Systems in ECS 1.0 - • How to Use SYSTEMS in ...
    💻 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 - DOTS + Input System
    - 2:27 - Steps for Handling Input in DOTS
    - 4:50 - Two Ways to Read Input
    - 6:14 - Creating the Input Asset
    - 10:08 - Continuously Reading Input
    - 12:40 - Writing to the Input Component
    - 14:20 - Moving the Player
    - 15:50 - Event Based Input
    - 17:54 - Resetting the Input Component
    - 18:31 - Final Demonstration
    🌐 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

КОМЕНТАРІ • 93

  • @Unity3dCollege
    @Unity3dCollege 10 місяців тому +9

    Awesome! Excited to start seeing all these tutorials on DOTS, may have to make the switch sometime soon :)

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      Ooooohhhh 👀👀👀

    • @evanfield6720
      @evanfield6720 10 місяців тому +2

      Indeed, I was generating mineral fields (24K objects) in my game using monobehavior and a Poisson disc sampling algorithm to keep them dynamic and getting a baseline of 130 FPS, converted those over to ECS and got that baseline up to 397 FPS. It is well worth the learning curve to get it done just to allow high performance on lower end platforms.

  • @khh1990
    @khh1990 9 місяців тому +3

    drink every time Turbo says "you know"

    • @TurboMakesGames
      @TurboMakesGames  9 місяців тому +3

      You know, that sounds kind of dangerous 💀💀

  • @alexadach5507
    @alexadach5507 10 місяців тому +7

    hey man I just want to say you deserve way more views/subscribers than you actually have. As someone learning ECS in 2023 your videos have been a godsend. Keep cranking them out, especially now that 1.0 is out. They're incredibly useful thank you.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      Thank you so much for the kind words. Got plenty more videos coming 😀

  • @raulfernandez6735
    @raulfernandez6735 10 місяців тому +3

    Grabbing my popcorn, here we go! 🍿

  • @DapperDinoCodingTutorials
    @DapperDinoCodingTutorials 10 місяців тому +2

    Thanks Johnny, I'm finally revisiting DOTS after a few years and these tutorials have helped me catch back up to the new way of doing things :)

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Right on Nathan! Excited to see the cool things you make with it 😀

  • @jdigi78
    @jdigi78 10 місяців тому +2

    Thank you SO MUCH for this. Been waiting for a good tutorial for some time 👍

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Hahah it's been a long time coming 😀

  • @epaezrubio
    @epaezrubio 10 місяців тому +1

    I can't wait to put this into practice :) Thank you for your amazing contribution to the game development community! All your tutorials are excellent and this isn't an exception.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Thank you so much for the kind words. Can't wait to see where you take this 😀

  • @BlackStrife3D
    @BlackStrife3D 10 місяців тому +1

    Exactly what I needed when I needed. Thanks!!!

  • @evanfield6720
    @evanfield6720 10 місяців тому +2

    I have been lurking in the ECS world for a few years now waiting for a 1.0 before attempting a conversion due to the imminent codebase changes we all knew were coming. It is great to see you staying on top of it as most content is outdated coming in this new release of the ECS package. Kudos to you for sharing your journey with us for the last few years!

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Thanks for the kind words! All the best if you do decide to give it a proper go now that 1.0 is out 😀

  • @rogercabo5545
    @rogercabo5545 10 місяців тому +3

    At times, I find myself pondering why we don't need to utilize a two-layer, double-pass authentication hybrid, unmanaged interop-dots-api just to access the value of a single button. A few years ago, I could code something like if (JS_Button.Xyz) and was immediately able to launch the logic - and it worked flawlessly right out of the box. Nowadays, in Unity, it feels like you need an advanced degree just to query a controller input. But thanks to spend so much effort into this topics! 👍

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      LOL! It certainly is more complicated, but it does have a lot of flexibility

  • @DrGroo
    @DrGroo 10 місяців тому +1

    Thanks for the tutorial. This was a great topic. It's not always obvious how to hook up non dots-specific parts of unity with the DOTS/ECS application model. This was a nice explainer.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Awesome, thank you so much for the kind words! Glad it was helpful 😊

  • @koukaakiva
    @koukaakiva 10 місяців тому +2

    Thanks for the tutorial. As for a suggestion you asked for at the end of the video, I would love to see some of your old tutorials updated for 1.0 (specifically the Unit Selection ones).

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +2

      Awesome, glad to know you'd be interested in that. Currently working on something that uses some unit selection like this, so may be able to whip up a dedicated tutorial on that hopefully soon 😊

  • @ericr4025
    @ericr4025 10 місяців тому +1

    Really good tutorial. I've actually started implementing some DOTS systems for fighting game inputs, and this first system that stores the input and writes it to a component in the update is something I was guessing at. Reassuring to see someone with more experience land on something similar :)

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Oh cool, sounds like a fun project! Feel free to share your progress in our Discord community if you'd like - tmg.dev/Discord

  • @TriCombStudio
    @TriCombStudio 10 місяців тому +1

    Was just attempting to convert my project to DOTS and wasn't confident in my approach, this helped clear things up. Thank you yet again. Lol

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      Awesome, glad to hear this was helpful to you 😊
      And feel free to ask in the Discord if you're stuck on anything else in your conversion process - tmg.dev/Discord

  • @amir._.nazarpour
    @amir._.nazarpour 10 місяців тому +1

    thanks for this information

  • @NeilDonkin
    @NeilDonkin 10 місяців тому +1

    Very interesting to see how events are used in the ECS world.
    Thanks

  • @yudanaim6849
    @yudanaim6849 10 місяців тому +1

    Very cool tutorial i would love to see more of it. You will be the new brackeys for ECS. :)

  • @roffy4373
    @roffy4373 9 місяців тому +1

    One day, someone will make a 100 hours compilation video with all the times you said "we're gonna go ahead", thank you for your work it helps

  • @Maskedmous
    @Maskedmous 10 місяців тому +2

    The things I still find challenging is Animation and AI. 2 very important systems in any game.
    So for example in a city you would simulate lots and lots of citizen / traffic.
    Having citizen walk streets from one point to another considering traffic lights and cars etc.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      Definitely agree on the importance of those features in any game.
      For animations, here are some of the current options available to you - forum.unity.com/threads/dots-animation-options-wiki.1339196/
      And I definitely would like to approach the topic of some different AI implementations soon!

  • @scrt9561
    @scrt9561 10 місяців тому +1

    Great Job! I'm a huge fan of your content and hope you will help me add new features to my games as I build using ECS. I'll be in touch and comment with some new features I would like to see added that match my C# code in this player input system but I think I have all that I need thanks to your Full ECS 1.0 video. If not, I look forward to reaching out.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Awesome, so glad to hear it! Feel free to join our Discord community and share your progress/ask questions there as well! tmg.dev/Discord

  • @mayank4156
    @mayank4156 8 місяців тому +1

    DOTS looks complicated for a beginner lol. Thanks for all the help! ❤

    • @TurboMakesGames
      @TurboMakesGames  8 місяців тому

      haha indeed it can be quite complex, but it is worth it if you need the extra performance. Hoping these videos can make it more approachable though!!

  • @MantridJones
    @MantridJones 10 місяців тому +4

    Before we're gonna like the video, we're gonna go ahead and leave a comment.

  • @ppreshh
    @ppreshh 10 місяців тому +1

    Super appreciate your content man. Very few ECS folks at the moment it seems. I'm still wrapping my head around all of it right now, and I've never really done DOD before. I think it would've helped to see you walkthrough your thoughts as you're writing out the code. I'm still missing here how your player object in the scene is being hooked up to the movement scripts. I assume it's because the GO's got that player tag component and more on it through some authoring process. Still making the mental switch from GO to entities in the scene hierarchy as well. I'm slowly getting there I think o.O

    • @ppreshh
      @ppreshh 10 місяців тому

      Just saw you linked the project files! That should be plenty helpful. tytyty

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Thanks for watching, good to know you'd be interested in learning some more about the main DOD concepts!

  • @Octamed
    @Octamed 10 місяців тому +1

    So basically SystemBase is just a replacement for normal managers and non-dots type code in the main thread? Then you kind of trigger work via the already running entity systems?

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      That is one way to use them, yes. You'll also see in my recent UI video, I use them to invoke events to update UI.

  • @HeyWhoTheFuckAreYou
    @HeyWhoTheFuckAreYou 10 місяців тому +1

    What about IK Animations in Unity DOTS? Will there be videos on this topic? As far as I understand, now you still need to use MonoBehaviour for this, since Animations Rigging itself is written in MonoBehaviour?

    • @SpiritedSeeker
      @SpiritedSeeker 10 місяців тому +1

      Yeah, that's how I am doing it now. Syncing the transform and animator from ECS to the rigged animator that lives outside of the ecs world. I do it by instantiating the prefab on start and remembering the references by using class versions of the IComponentData (unmanaged components). Wayn has a tutorial about this.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      That's correct. I definitely would like to put up some good videos on Animation in ECS in general, but good to know you'd like to learn about IK animations specifically

    • @evanfield6720
      @evanfield6720 10 місяців тому

      You can actually bake in the animations into the Entity itself and progress them through code. There is a good asset out all ready that will allow you to accomplish this called "GPU ECS Animation Baker", It is pretty straight forward to use it and the video demonstration is sufficient enough to get it up and running. Here are the tutorial videos he made for the application of the asset, ua-cam.com/play/PLerop1JzrAobUF2d8Iafj5waqSq3Ib8k1.html, buying assets is of course just the prelude to dissecting the code in them to see the path that was used to accomplish the task.

    • @LukeClemens
      @LukeClemens 10 місяців тому

      ​@@evanfield6720That won't support IK. As far as I know the only DOTS option that supports IK is by synchronizing legacy game objects with ECS. The DOTS Animation Options Wiki lists a lot of options, but none support IK at the moment. The Kinemation framework from DreamingImLatios has it on the roadmap.

  • @boringkillerstudio5880
    @boringkillerstudio5880 10 місяців тому

    That's Great Video, I have been following your tutorials on ECS. And I have implemented into Surviver Game that's looks good but Now I'm unable to add Animation I have tried many things but couldn't work for me. So could you please make a Tutorial on Human Animation in ECS it will be great help for many dev out there. Thanks

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      Awesome, that's super cool to hear about your game. Feel free to share your progress on our Discord if you want - tmg.dev/Discord
      Yep, animation is a topic I really should cover a bit more. For now, here is a good forum post detailing the current animation options available for ECS - forum.unity.com/threads/dots-animation-options-wiki.1339196/

  • @nickgennady
    @nickgennady 10 місяців тому +1

    It would be cool if you showed how to do skeletal mesh animations using DOTS
    Maybe instead if there is no native way to do skeletal mesh in dots (even procedural animation) you can show us good practice of binding game object and it’s components to a entity in efficient way

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Thanks for the suggestion! Animation is definitely an important topic, but one that I want to approach in the right way when I get to it.
      For now, here are some of the current available options - forum.unity.com/threads/dots-animation-options-wiki.1339196/

  • @JunkerJames
    @JunkerJames 10 місяців тому +1

    Hoping w get gyro feed from controllers. Last time I looked it wasn't available. Had to use Rewired.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      I know for sure you can look at gyro data for VR controllers, unsure about console controllers though

    • @JunkerJames
      @JunkerJames 10 місяців тому

      @@TurboMakesGames yeah. I think there's some issues with official driver support. You kinda have to go down the route of reverse engineered drivers since there aren't ubiquitous standards yet. Ah well.

  • @StealthNinjaK
    @StealthNinjaK 10 місяців тому +1

    Could you do a video on how you would use a mixamo character & animations in dots?

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      Definitely going to be doing some things on animation soon, so glad you'd like to know how to use a mixamo character 👍

  • @UngodlyDev
    @UngodlyDev 10 місяців тому +1

    is it easy enough to make the controls rebindable? right now im using the player input component on a gameobject for my controls and i can rebind the controls in the ui, can this same logic apply to that workflow?

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Great question - Yes, but you'll have to go through some extra steps to support this. Here is a thorough tutorial that shows how to do this with the generated C# class - ua-cam.com/video/TD0R5x0yL0Y/v-deo.html
      Also, it might be worth taking a look through the documentation on the input system and try some of those options - docs.unity3d.com/Packages/com.unity.inputsystem@1.6/manual/ActionBindings.html#changing-bindings
      Alternatively, you could use a managed data component, where you can store and reference your existing player input component in an ECS system. docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-managed.html

    • @UngodlyDev
      @UngodlyDev 10 місяців тому

      @@TurboMakesGames thanks a ton

  • @jmguillemette
    @jmguillemette 10 місяців тому

    Dumb question but what asset / material are you using to get the floor plane with correct 1x1 cubes on it?

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Gridbox Prototype Materials! Free on the Unity Asset Store
      assetstore.unity.com/packages/2d/textures-materials/gridbox-prototype-materials-129127?aid=1101l9vRP
      Be sure to use it with ProBuilder so the texture tiles properly

  • @MarkChong
    @MarkChong 10 місяців тому +1

    Would like to hear how to set up addressable assets for modding with DOTS and Steam Workshop

  • @SuperKemito
    @SuperKemito 10 місяців тому +1

    Any tips/ideas how to work with animations when using ECS/DOTS?

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      Here are some of the current available options - forum.unity.com/threads/dots-animation-options-wiki.1339196/

    • @SuperKemito
      @SuperKemito 10 місяців тому

      @@TurboMakesGames Thank you

  • @jerms_mcerms9231
    @jerms_mcerms9231 10 місяців тому +1

    That input action listen ui bug is super annoying. Hope it's fixed soon!

  • @lmao01
    @lmao01 10 місяців тому +1

    I'm a little cofused not with this simple example but with more complex input system where other things at the same time should be enabling and disabling some inputs.
    I.e. You have player movement input enabled at start.
    The input can be disabled by inventory and map.
    Then player opens up inventory ui so the ui forces to disabled.
    On top of it opens map. There is no change in input since its already disabled.
    Then it closes the map. The movement is enabled yet it shouldn't because the inventory is still on.
    What I have done is in singleton with
    public Dictionary disallowed; string is an action ID.
    I add every single component which disallows action. And refer with every steering component this the singleton.
    It works yet, It feels like I am doing something wrong. Like I am skipping input system package in some way.
    I was trying to search for this information yet everyone shows very basic cases with input system.
    Maybe not the correct place to ask it.
    Either way good work and thanks for the tutorials.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Thanks for voicing your concerns for your use case. Unity's input system has a ton of features you can take advantage of that may be able to help you. For instance you can have different control schemes that essentially group individual controls a user has access to. So rather than disabling the full input asset, you can just change which control scheme is active at a given game state. Hope it helps your research into the input system!

  • @MrHandsy
    @MrHandsy 10 місяців тому

    Would I be able to purchase some personal advice regarding ECS from you?

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому

      Reach out to me via Discord or email and we'll see if we can work something out!
      tmg.dev/Discord
      contact at tmg dot dev

  • @vakuzar
    @vakuzar 10 місяців тому

    This is great! now lets make Vampire survivor XD !
    or an RTS prototype could be cool.

    • @TurboMakesGames
      @TurboMakesGames  10 місяців тому +1

      I recently did make a Vampire Survivors clone! Try it yourself, it was a super fun exercise.
      I've got something in the works that I think you'll enjoy though 😊

    • @vakuzar
      @vakuzar 10 місяців тому

      @@TurboMakesGames yeah! I saw that! looked so cool I wanted to try myself, but I don't know where to start on tutorials for ECS since I've been waiting for 1.0. Now that it's out I wanna dive in, but I feel like most resources are dated and might not be compatible. That's why a from scratch one is so interesting to me.

  • @alexpopov1902
    @alexpopov1902 8 місяців тому

    can't see actor in webgl

  • @andhikadimas6345
    @andhikadimas6345 8 днів тому

    too many time jump in script, i am confuse.

  • @Luciferdelight
    @Luciferdelight 4 місяці тому +1

    What is the difference between what you are doing, i guess you are just coding everything yourself, but in the new input system you usually set an Player Input component on the player and choose behaviour, (Send messages or Invoke C sharp events)
    Is this unusable when you using dots and is that the reason you do what you do.
    And if not, what would you (or anyone in the comments) say you loose out on by not using the player Input component instead ?
    I really cant wrap my head around this
    Any answere is appriciated

    • @TurboMakesGames
      @TurboMakesGames  4 місяці тому +1

      With ECS you can't use regular Unity components in the same way as game objects. There are ways you can reference Unity components from ECS, but for hooking into input events it ends up being even more cumbersome than what I've shown here. The biggest thing you lose out on is just the convenience of setting up things in the editor - which can be nice if you are working on teams where you want to give people the ability to tweak certain things about the input without having to open up the code.

  • @ashpats2
    @ashpats2 4 місяці тому +2

    Why is it when I copy all the scripts into a fresh project I get errors, but when I download and launch your project on the same Unity version, it runs cleanly?
    ```InvalidOperationException: The previously scheduled job PlayerMoveJob reads from the ComponentTypeHandle PlayerMoveJob.JobData.__TypeHandle.__TMG_InputSystemTutorial_PlayerMoveInput_RO_ComponentTypeHandle. You must call JobHandle.Complete() on the job PlayerMoveJob, before you can write to the ComponentTypeHandle safely.```

    • @jayvander5770
      @jayvander5770 2 місяці тому

      try adding Dependency.Complete() before calling SetSingleton( new PlayerMoveInput)...

    • @simleGuy
      @simleGuy 22 дні тому

      @@jayvander5770 tnx man.