Control Units and Give Orders in Unity ECS!

Поделиться
HTML-код
  • Опубликовано: 11 янв 2025

Комментарии • 100

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  5 лет назад +7

    🤖Join the Community Discord discord.gg/eHjUVrm

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  5 лет назад +26

    Really cool simple RTS controls, stay tuned for a complete RTS mini game based on the Marines Vs Zombies video!

  • @wertin200
    @wertin200 5 лет назад +15

    The video i have being waiting for since the release of DOTS

  • @apubetico
    @apubetico 5 лет назад +1

    thanks for listening and i appreciate your hard work by finally bringing rts tutorials with new unity.
    i got stuck on my own when doing the one click selection, pretty smart solution you gave me.
    your videos are starting to be for more experienced coders btw. keep up the good work!

  • @chikato7106
    @chikato7106 5 лет назад +13

    This is such an incredible tut!!!
    Now I wonder how would you handle the state machines. Would you make a director or do the individual entities decide. I also wonder how you would get an AI to maybe be a director and behave like a player in a kingdoms battle, Age Of Empires II style.

  • @siarheipilat8152
    @siarheipilat8152 5 лет назад +6

    bro, you are crazy! is this the best youtube unity dev channel!?

  • @Bruugle
    @Bruugle 4 года назад

    I'm not sure it would have any significant performance benefit but, in your ForEach parameters using "in" instead of "ref" before the component reference makes the component you are accessing readonly. You could do this before all of your Translation references where the translation is not being directly modified inside the loop. In the documentation they say doing this increases efficiency quite a bit and from my own tests it really does. just make sure you call all refs before ins. Anyway, this tutorial has been very helpful for learning an underlying design for a selection feature. Even though I'm making mine a 3d version with a full degree of motion camera, this helped me make a starting point, thanks!

  • @adamodimattia
    @adamodimattia 5 лет назад +2

    Not event started this tutorial and I’m already blown away! Thank you!

  • @realmasterkush
    @realmasterkush 5 лет назад +1

    You deserve much more subs. Thank you for making my life easier.

  • @geri4367
    @geri4367 5 лет назад +1

    Really taking off now! Amazing stuff!

  • @millerhall5301
    @millerhall5301 5 лет назад +1

    Why anyone would disllike this great work!

  • @BeerfootBandit
    @BeerfootBandit 5 лет назад +1

    Thanks alot! It seems like i came to the right channel to learn about all this ecs and jobs stuff

  • @mamut2
    @mamut2 5 лет назад

    I love this channel!

  • @juvebuffon100
    @juvebuffon100 5 лет назад +1

    Thank you for this video.

  • @Sachinkumar-ku6ji
    @Sachinkumar-ku6ji 5 лет назад +1

    Nice one man

  • @4yougamez254
    @4yougamez254 2 года назад

    you r amazing bro

  • @CodyNewhouse
    @CodyNewhouse 5 лет назад +1

    Great stuff.

  • @Lei_Desuu
    @Lei_Desuu 5 лет назад

    i just saw an ad and ill follow

  • @mohamedessam-6228
    @mohamedessam-6228 5 лет назад +1

    i love it.. thank you.

  • @CalicoArchives
    @CalicoArchives 4 года назад

    Does this tutorial work with the current version of ECS in Unity 2020.2?

  • @andrew.r.lukasik
    @andrew.r.lukasik 5 лет назад +1

    I found Entities.Foreach an super easy prototyping utility but near useless (performance wise) in production. In the end it all needs to be ported to threaded jobs

  • @renatopereira2315
    @renatopereira2315 5 лет назад +1

    Are you planning on making a tut on exactly this but taking into account terrain that blocks the units movement ? Using ECS of course

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +2

      That's tough because right now the Unity Navmesh system doesn't work very well with ECS so doing that involves writing your own ECS based Pathfinding system.
      Certainly something I'd like to cover in the future though.

  • @peterquill726
    @peterquill726 5 лет назад

    Hey Code Monkey, I've found out from your old videoห that the main massive performace gain from the new workflow is through using JOB and Burst. So I find ECS to be too troublesome for its own worth. Most of my old projects are architeched in a callback system. How do I achieve what's equavalent of callback using JOB ?

  • @Malkat21
    @Malkat21 5 лет назад

    Thx for the Tutorial :) Do you make a pathfinding Video to?

  • @GreenHunterTV
    @GreenHunterTV 5 лет назад

    You genius, man

  • @MalikenGD
    @MalikenGD 5 лет назад +2

    Is ECS also Data Driven Design/Data Oriented Design? Are they one and the same?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      Yup, ECS is one of the pillars of DOTS (Data Oriented Technology Stack)
      Check out the video where I cover what is DOTS and what are the pillars ruclips.net/video/Z9-WkwdDoNY/видео.html

  • @kken8766
    @kken8766 4 года назад

    god damn!! you made it look sooooo easy...
    great job...
    next question... how would you make them move into formation?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад +1

      Create a class where you can hold a list of Units and dynamically calculate valid positions based on the number of units and have that class tell each unit where to go.

    • @kken8766
      @kken8766 4 года назад

      @@CodeMonkeyUnity wow thanks for the pointer, i'll try it out~ love 3000~~

  • @burak9100
    @burak9100 5 лет назад +1

    Hi. Where do you design your characters, weapons etc.?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      They are drawn in Photoshop, you can see how the sprite sheet is set up in the project files.

  • @vmmi8215
    @vmmi8215 4 года назад

    is there a way to move character in DOTS using analog joystick?
    i'm currently develop an android game using DOTS but get stuck at input and control
    anyway amazing video as always, i appreciate whole of this DOTS tutorials

  • @Random4Logic
    @Random4Logic 5 лет назад

    Any idea how you would do such a selection rectangle in a 3d game ? I used to do it with the gui, but you cant access the gui from a system (or i dont know how) and also i dont know if you can return values from the system to your controller script somehow.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      You can access it inside a ComponentSystem since its still on the main thread, just not inside a Job. For a 3D game you would just use the X and Z coordinates instead of Y.
      You can ask the entity manager to get some component data or when inside a system use some sort of static class to get a reference to whatever script you want to access.

    • @Random4Logic
      @Random4Logic 5 лет назад

      @@CodeMonkeyUnity thanks for the answer i sort of understand what you mean with the second answer. But for the first: in my tests i can only access the OnGUI() function from within a class that inherits MonoBehaviour and not from a ComponentSystem. So do you mean i make the onGUI public in my Monobehaviour script and call it within the ComponentSystem by using an static instance like in your video? EDIT: obviously calling the OnGUI manuell is stupid... so now i just pass the needed data from ComponentSystem to the Controller script by setting variables over the static instance. That seems to work.

  • @tunghaotu8652
    @tunghaotu8652 5 лет назад

    this video is awesome, Will you make a video about animate the humanoid model ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      It's a Mesh based animation system, check this video: ruclips.net/video/11c9rWRotJ8/видео.html

  • @entchenkleinente5747
    @entchenkleinente5747 5 лет назад

    thx you saved me

  • @BeerfootBandit
    @BeerfootBandit 5 лет назад

    Can this or your other unity2019 tutorials work in Unity 2018.3?

  • @paktofu123
    @paktofu123 5 лет назад

    I like your series. But I’m a bit hesitant to switch to ecs right now as I’m just grasping c#, and I also noticed that the ecs versions are still very early. Do you think there will be massive changes to ecs as it approaches a release version?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      ECS isn't going to be forced upon you, it's just another tool. Whether it's the best tool depends on what you're doing.
      If your game works well with MonoBehaviours then keep working that way. If you have a specific Performance heavy section of your game then look into ECS for that specific part.
      It's still in development but I believe from now until release late this year there won't be any massive changes like in March.

    • @davidpak271
      @davidpak271 5 лет назад

      @@CodeMonkeyUnity Thanks, I think I will get started on ECS too then

  • @fynjy1992
    @fynjy1992 5 лет назад

    Hi Code Monkey! It would be awesome if u make a video ab single preselected character moving - using same input method and with pathfinding option. Would it be possible to see such thing on your channel?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      So just one character? That would be the same except the selected character would never change.
      Check out the Gatherer AI Playlist

  • @equious8413
    @equious8413 3 года назад

    Hmm.. I can't get my pixel sprite to align to 0,0 on it's parent gizmo ... :(

  • @daslolo
    @daslolo 5 лет назад

    When I crank up the number of soldiers to 3000 it's horribly slow at 35ms just in script, I'm not sure this is faster than raw monobehaviour... have you run some test? And burst doesn't change that, so perhaps this is the animation system.

  • @mcasterinoprojecterino6435
    @mcasterinoprojecterino6435 4 года назад

    The selection area behaves erratically for me. When I click and drag, the sprite selection area moves to the position of the mouse but does not scale properly. I have followed exactly what you did and was still unable to fix this. Do you know what it could be?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      Make sure you set the sprite Pixels Per Unit to match the Texture Size

    • @NathaNeil27
      @NathaNeil27 4 года назад

      So I was having problems with my selection area scaling properly. I figured out it was because I put my selection area object as a child of a canvas that automatically scales with screen. When the screen changes size, the scale of the canvas changes. So I figured out how to get a reference to the parent canvas and divide the selectionAreaSize with the scale of the parent canvas. Works perfectly now.
      mySelectionTransform.localScale = selectionAreaSize / mySelectionTransform.parent.localScale;
      *Edit: Make sure to use an if statement to make sure the parent canvas is active before trying to run any of this code. If you don't you might get an error message because it is unable to get the scale when it is disabled.

  • @darkness7509
    @darkness7509 5 лет назад

    How did you create RTSControl script??

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      It's just the basic set up script, just creates the entities.

  • @31337flamer
    @31337flamer 5 лет назад +1

    just a small tipp .. write "for" and hit "tab" 2 times.. be surprised .. use tab and more of the visual studio hotkeys :D your missing smth.

  • @ArnCiS96
    @ArnCiS96 5 лет назад +1

    @CodeMokey can you upload code to github?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      You can download the full project files from the website.

    • @ArnCiS96
      @ArnCiS96 5 лет назад

      @@CodeMonkeyUnity Sure I can, but in github previewing is more comfortable, why not?
      When I need someone to show something is just send a link to commit or line in code, this is way is better for education and explanation.

  • @panupundev7038
    @panupundev7038 5 лет назад

    Thank :)

  • @en-yuchang6026
    @en-yuchang6026 4 года назад

    What does Codemonkey.Uyilis do?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      It contains a bunch of utility and helper functions and classes. The source code is all there so check it out.

  • @Unknown-tz4rs
    @Unknown-tz4rs 4 года назад

    I installed package but i cant use it can someone help me with setup?

    • @Ankhtepot
      @Ankhtepot 3 года назад

      Just downloaded and now investigating if it's even usable anymore in 2020.2. Which is not CM fault of course, ECS is jumping forward all the time. Great video!

  • @emperorofsparta410
    @emperorofsparta410 4 года назад

    where can i find the script?

  • @andre1954
    @andre1954 4 года назад

    Does it work for 3D?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 года назад

      Sure, the main difference is changing how you grab the mouse position, instead of ScreenToWorldPoint you do a Raycast

  • @littlearvin1641
    @littlearvin1641 5 лет назад

    Do this this this this this this TADAAAA! :')

  • @elespumosoxd7828
    @elespumosoxd7828 5 лет назад +1

    Grácias.

  • @TheFlakkenTime
    @TheFlakkenTime 3 года назад

    Pre warning for anyone wanting to learn. A large number of the library names have been changed and this will not work in the newest version of Unity. I went through and updated the function calls where I could find the new name. This got it to run however it was throwing errors and not working correctly.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 года назад

      What errors did you have? The only thing I can think of is the Lightweight Render Pipeline which is now URP. The RTS controls themselves don't have anything related to any version.

    • @TheFlakkenTime
      @TheFlakkenTime 3 года назад

      @@CodeMonkeyUnity sorry I just saw this.
      1. In 2020.3.12f1 I open up a new 3d project
      2. I import the ECS_RTSControls download
      3. I have 81 critical errors and a few warnings.
      First errors like: namespace 'Entities' does not exist in namespace 'Unity'. Also including Mathematics, Transforms, IComponentData, JobComponentSystem, etc.
      After reading various pieces and your video says "Unity ECS" I read to install this via git URL with: com.unity.rendering.hybrid as this is a test feature not fully released.
      4. This gets us down to 4 critical errors and now we're up to 17 warnings
      The type name 'Concurrent does not exist in the type 'EntityCommandBuffer'. From my reading the other day I found a post saying this was renamed 'EntityCommandBuffer.ParallelWriter'
      5. TimeData does not contain a definition for 'deltaTime' this appears to have been made 'DeltaTime'
      6. 'World' does not contain a definition for 'Active' again from my reading this was replaced with 'World.DefaultGameObjectInjectionWorld.EntityManager'
      7. 1 critical error left "EntityCommandBuffer does not contain a definition for "ToConcurrent". This one I could not find anything online so I tried it with "AsParallelWriter" from the autocomplete as it was the only option.
      At this point it has some warnings and 0 critical. Running it just fills the console with errors. Not sure what else I did the other day when I spent a few hours on this. But in that one I was able to get it to render a black background and it slowly spawns random soldiers.
      I appreciate any help. I'm actually a full time dev that just thought goofing with Unity would be fun. Unfortunately, I've done about 8 tutorials from various sources including learn.unity and I've found 1 that worked exactly as described. All the others ran into some issue with UI or library changes that I had to tweek to get them to work properly.

  • @orkun441
    @orkun441 5 лет назад

    this video is so good but also too hard for me :/ i wish you could do more easy stuff

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      I try to vary the difficulty in the videos, some cover easy topics and some more difficult.
      Check out the video list, there's 200 videos already and I'm sure you'll find something just perfect for you!

  • @ehsanafzal185
    @ehsanafzal185 5 лет назад

    Whats is delegate and event
    Plz make a tutorials on that

  • @juandiegobricenomadueno2121
    @juandiegobricenomadueno2121 5 лет назад

    make a iron man and hulk good videos

  • @MatherFarker
    @MatherFarker 4 года назад

    yr name is Jeff?

  • @daslolo
    @daslolo 5 лет назад

    cannot find using Unity.Rendering

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад

      Make sure you have the Hybrid Renderer package in your project.

    • @daslolo
      @daslolo 5 лет назад

      @@CodeMonkeyUnity I removed all using Unity.Renderer and it worked. what's the difference with the hybrid renderer?

  • @ricardomilos857
    @ricardomilos857 3 года назад

    wtf codemonkey library???

  • @Jackal5336
    @Jackal5336 5 лет назад

    this tutorial is useless to me, you did a lot of stuff typing really fast and dont explain enough what youre doing. had the video run at 50% speed and still wasnt able to follow up whats happening. didnt even figured out how to start the script you mentioned at 5:00.. if youre already a pro you can go on with this video, if your new to unity its a waste of time

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +2

      Well this is a ECS video so by definition it's more advanced than normal.
      If you're a beginner you should look for tutorials using normal Game Objects.

    • @Jackal5336
      @Jackal5336 5 лет назад +1

      @@CodeMonkeyUnity maybe you should consider to make it more clear on the title, since until i watched this video i had no idea what ECS means

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +3

      @@Jackal5336 The video is titled "in Unity ECS!"
      I understand how it might cause confusion if you have no idea what ECS is but I cant explain the difference in 10 characters.

  • @Spy090channel
    @Spy090channel 5 лет назад +2

    useless system since you have to write a lot of hard code to achieve simple results such as you don't have unity gameobjects that are easy-to-use, so it's very hard to level-design even simple RPG location. Also as I understand there is no way to animate gameobjects using built-in unity animator. So tell me please why I should use it?
    For huge game like an RPG it will be extremely hard to use this system and will take around 100x more time to make a game.
    But a simple game that is quite easy to make with ECS system don't even need so much performance even on mobile devices.
    So what's the point to use it?
    Tell me if I messed up smth or misunderstood

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +2

      As always, use the right tool for the job, you don't have to go full ECS or full GameObjects, you can mix them.
      So if you have a performance bottleneck, like running the AI on hundreds of enemies in your entire RPG World, consider using ECS for that portion.
      For designing the world, placing all the objects and making simple event triggers go with Game Objects.

  • @Elderny
    @Elderny 5 лет назад

    Hey monkey i like ur videos but u are not getting views + subscribers because u are only uploading the tutorials
    Try to uploads videos like a day in the life of ******
    Or
    Created a game in 48 hours
    Or
    1 hour in the life of game dev

    • @tudordumitrescu8707
      @tudordumitrescu8707 5 лет назад +6

      ELDERNY TECH he is better than that. More and more people will see it and they will view his videos.

  • @WalterRDK
    @WalterRDK 5 лет назад

    Omg.. this is a mess or too radical.., is more easy go for Unreal and C++ if you need extra performance

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  5 лет назад +1

      What specifically did you find messy?
      Data Oriented code is different from Object Oriented but once it clicks it becomes quite elegant.