Control Units and Give Orders! (Unity RTS Tutorial)

Поділитися
Вставка
  • Опубліковано 20 кві 2020
  • ✅ Get the Project files and Utilities at unitycodemonkey.com/video.php...
    Let's make a Simple RTS Control System to Select our Units and Give Orders.
    This is a great base for you to expand upon, add more actions, different types of units, etc.
    Stay tuned for an upcoming video covering how to make Custom Animated Cursors so we can make the game look better and give the player more context.
    Control Units and Give Orders in Unity ECS!
    • Control Units and Give...
    Modular Character System in Unity
    • Modular Character Syst...
    Patreon Sponsor: www.badadventurer.com/
    We're going to start off with a basic Unit standing Idle.
    First we capture the Mouse Down and Mouse Up events and store the Mouse World Position, using that we can then use Physics2D.OverlapAreaAll which returns all the Colliders within two points
    Then we create a script to identify our Units and ignore objects like Rocks. We add a Visual for the Unit Selection and the Selection Area.
    After that we add the ability to give our Unit a simple Move Order. The Unit is handled by the Modular Character System created in a previous video so we can easily add some move behaviour.
    With the Units receiving orders then we dynamically generate some positions around the Target Move Position and send each unit to a different position in order to prevent overlapping.
    And with that the RTS Control System is done!
    You can use this as a base for your RTS Games and Expand upon it by adding more actions and behaviours like Attacking Enemies, Constructing Buildings, Gathering Resources and so on!
    If you have any questions post them in the comments and I'll do my best to answer them.
    🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
    See you next time!
    📍 Support on Patreon / unitycodemonkey
    🤖 Join the Community Discord / discord
    📦 Grab the Game Bundle at unitycodemonkey.com/gameBundl...
    📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
    #unitytutorial #unity3d #unity2d
    --------------------------------------------------------------------
    Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.
    I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
    You can see my games at www.endlessloopstudios.com
    --------------------------------------------------------------------
    - Website: unitycodemonkey.com/
    - Twitter: / unitycodemonkey
    - Facebook: / unitycodemonkey

КОМЕНТАРІ • 345

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  4 роки тому +64

    Here's an RTS Tutorial! Would you like to see more? I've always wanted to make a mini-AoE!
    🌐 Have you found the videos Helpful and Valuable?
    ❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php

    • @tyleranders9972
      @tyleranders9972 4 роки тому +2

      Great vid. I'd like to see more rts stuff.

    • @lutzoffun2459
      @lutzoffun2459 4 роки тому +2

      More rts videos would be really appreciated! :)

    • @JovsValorant
      @JovsValorant 4 роки тому +1

      Please continue great monkey coder😍

    • @blakeguyan2662
      @blakeguyan2662 4 роки тому +1

      Yeah, I am planning on leveraging this into a formation system... out of curiosity, i grabbed the files for your "player movement" tutorial but it was lacking the sprites/textures... is that intentional or am i missing something?

    • @hellsing280391
      @hellsing280391 4 роки тому +2

      A mini-AoE from scratch would be awesome

  • @pixspaces4777
    @pixspaces4777 4 роки тому +69

    Wow RTS tutorial.. we definitely need more of these from you!

  • @madeirander
    @madeirander Рік тому +9

    This video is a priceless gem! It's hard to find good RTS unity tutorials out there. I was doing it on my own, it kinda worked, but then I stumbled upon your video, which was doing the same but insanely simpler! LOL

  • @JovsValorant
    @JovsValorant 4 роки тому +42

    Who else love to see more RTS Tutorials? Count me in 😍

  • @Crisisdarkness
    @Crisisdarkness 4 роки тому +2

    This is one of my favorite genres, today I have met your channel (subscribed), wow you have surprised me, I have always had a motivation to create a video game focused on this genre, it would be very amazing if you could do more tutorials focused on this genre, which is very difficult find on youtube. You are an excellent instructor, I appreciate people like you who share their experience, thanks

  • @monkeysaur4305
    @monkeysaur4305 4 роки тому +3

    Yes please, an RTS series would be great! Thanks for your videos!

  • @maistrogaming7911
    @maistrogaming7911 4 роки тому +5

    Man I am crying saying I LOVE YOU
    .....MAN HOW GREAT YOU ARE HOW MAGNIFICENT YOU ARE....WOW THUNKS A LOTTTT....LOVE YOU PREACHING YOUR WORK A LOT

  • @albertrodriguez840
    @albertrodriguez840 4 роки тому +9

    I was searching how to make a game similar to AoE (maybe not as complicated) and I found this incredible channel. Please post more like this! :D

  • @NotSageMan
    @NotSageMan 3 роки тому +4

    i have always wanted to learn to make a rts similar to mowas2 and Company of heroes so I am very happy for this tutorial

  • @davkings52
    @davkings52 4 роки тому +6

    Stronghold Crusader Style Units Selection. I really liked this tutorial.

  • @blackfrogstudios6670
    @blackfrogstudios6670 4 роки тому +19

    Would love to see some more RTS tutorials

  • @xXYannuschXx
    @xXYannuschXx Рік тому

    This is incredibly useful! My friend and I are currently making a sort of RTS tower defense game, where you can order troops around in the style of Company of Heroes and build fortifications. I am currently working on the scripts for troop movement and needed an idea for how to move multiple troops in a fixed squad, without them running into each other.
    However I want to use a grid system to place the troops and buildings on the map and to keep the troops from running to the same position.
    Honestly, your tutorials not only help for special use cases, but also show programming techniques that can be used for other stuff. FAR more helpful than most stuff I have found, especially due to the explanations.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Рік тому +1

      I'm glad you found the videos helpful!
      If you're looking for a Grid System I covered something like that here unitycodemonkey.com/video.php?v=dulosHPl82A
      Instead of buildings you could place down Units, so it would be kind of like Civilization
      Then maybe use the code from this video to dynamically calculation the base unit positions and make them go back to those positions after they attack something

  • @mateuszpatua3016
    @mateuszpatua3016 2 роки тому

    thank you! best tuts on the topics which are nowhere else to be found! :D

  • @blakeguyan2662
    @blakeguyan2662 4 роки тому +14

    Hey man, I just wanted to tell you I am a Dev (web) and I worked as an artist in games for a while. i stumbled across your channel while i was looking to get back into writing some code for a couple of simple games for me and some friends to play for a laugh.
    This channel is amazing and you do a fantastic job, once i had watched a little of it i went directly to steam to get battle royale tycoon (which looks great btw) and picked up your bundle on your link, even if i never played the games i wanted to give you a little thank you for all of your hard work!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому +2

      Thanks! I'm glad you found the videos helpful!

  • @StigDesign
    @StigDesign 4 роки тому +126

    Please more rts tutorials so that i can make my own C&C game or RA2 or AOE :D

  • @lutzoffun2459
    @lutzoffun2459 4 роки тому +1

    Great video! I would be really happy about a rts series! :)

  • @johnnyxp64
    @johnnyxp64 4 роки тому +13

    YEEEEEEEESSSSS finally!!! some RTS series from one (if not THE) best channels for Unity on UA-cam! 😎♥️🥰👍👍👍 do not stop the series please this time! Game development is the hardest form of software development..and RTS the hardest form of game development...so few and rare complete RTS easy and good tutorials out there! there is a huge gap in today's version of Unity on this topic! be the protagonist the opportunity for countless vies is there! 🥰
    next videos should include base building...and gathering 1 resource. and i am going to become a Patreon now how did i skip that? 🙄 RTS ♥️4ever

  • @nock5th
    @nock5th 3 роки тому +8

    This isn't just useful for RTS and that's what I love about your videos. I'm currently learning bits and pieces for my action RPG. Keep up the great work!

  • @johnnyxp64
    @johnnyxp64 3 роки тому +3

    come back to this series please. everyone is asking for this!

  • @gamedevunlimited7834
    @gamedevunlimited7834 Годину тому

    great tutorial. has a lot of good info on how to make an rts. i learned a lot

  • @Sjomaz
    @Sjomaz 4 роки тому +1

    Awesome! Good job and thank you.

  • @Oxmond
    @Oxmond 4 роки тому +3

    Great tutorial! 👍🎓 Looooove real-time strategy games! ❤️🤓
    I used to play Red Alert all day long!!! 😝🤪

  • @AlistDocumentaries
    @AlistDocumentaries 2 роки тому

    Great Courses! Yup there you go!

  • @kken8766
    @kken8766 4 роки тому +3

    exactly what i need!! i love you so much...(bear hug)

  • @BingoGo2Space
    @BingoGo2Space 17 днів тому

    Thanks, this video helped me a lot

  • @drpainnuk3d
    @drpainnuk3d 4 місяці тому

    Great example thanks!

  • @mohammadtausifrafi8277
    @mohammadtausifrafi8277 2 роки тому +3

    Definitely one of the topmost channels for Unity tutorials, maybe the best even.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 роки тому +2

      I'm glad you like the videos! Thanks!

    • @mohammadtausifrafi8277
      @mohammadtausifrafi8277 2 роки тому

      @@CodeMonkeyUnity You are very welcome. And thank you very much for the reply.

  • @zenmasters_games
    @zenmasters_games 4 роки тому +16

    Like first, then watch hehe

  • @jaimealcantara8569
    @jaimealcantara8569 2 роки тому +2

    Hello! I would like to set the tiles in which the units stands as not walkable, so they cannot stay in the same one thus avoiding overlapping. I've thought about adding a collider to each tile to detect when it is occupied but I imagine it would be very expensive, and I have also seen the RaycastWalkable function but would not want to call it constantly as it must also be expensive. could you give me any hints on how to do it?

  • @The-devllopperBlogspot
    @The-devllopperBlogspot 4 роки тому +3

    Thank you man, you've gained a new Patreon Subscriber.

  • @edgardosanabria2486
    @edgardosanabria2486 3 роки тому

    Great tutorial thanks a lot

  • @mehmedcavas3069
    @mehmedcavas3069 4 роки тому

    again a great video

  • @mustafaagha8834
    @mustafaagha8834 2 роки тому

    Amazing tutorial

  • @WookieDay
    @WookieDay 3 місяці тому

    that's what i want! thanks!!

  • @cradle_of_chaos
    @cradle_of_chaos 4 роки тому +1

    This is excellent work.
    It would be great if you could link the actions in the next video to the Stats system you introduced in the Stats Radar Chart video.

  • @stevemaxwell4756
    @stevemaxwell4756 3 роки тому +4

    Will there be group selection, obstacle pathfinding and enemy combat tutorial using this rts system?

  • @JianjiPeppina
    @JianjiPeppina 4 роки тому

    Love u some much, thx for the video :)

  • @boxsowrd8542
    @boxsowrd8542 2 роки тому

    Thank you man at the future I just want to be a rts game maker but first i started at 2D game

  • @Tamdev9
    @Tamdev9 4 роки тому

    This is very useful

  • @turuncu3092
    @turuncu3092 4 роки тому

    Nice video good job 🖒👌

  • @DudeFrom1972
    @DudeFrom1972 4 роки тому

    Great video as always - please show how to select all of the same type of units on key down + mouse down.

  • @xX...I...Xx.
    @xX...I...Xx. 3 роки тому +3

    hello you can edit the formations of the soldiers for example 5 x 6 or 7 x 8 or you would have to do it selecting one at a time

  • @evanlemmons1492
    @evanlemmons1492 3 роки тому +6

    Any advice for adapting the unit grouping in `GetPositionListAround` for a 3d game where the units are along X and Z? I've been tweaking and they just keep standing in a straight line.

    • @evanlemmons1492
      @evanlemmons1492 3 роки тому +9

      Figured it out if anyone else is stumped here: in the `ApplyRotationToVector` method move the `angle` variable to the y position. this creates a circle around the y axis which is what you'd want for a 3d game whereas the `angle` being in the x position like in the tutorial is what you'd want for 2d.

  • @AaronAsherRandall
    @AaronAsherRandall Рік тому

    Hey Code Monkey, will this tutorial go together with the Builder Defender course you made? I am currently working through that course and want to make an RTS.

  • @gilleswalther5964
    @gilleswalther5964 4 роки тому

    Well done :-)

  • @Naruto-ss2ff
    @Naruto-ss2ff 4 роки тому +9

    I can't get a confirmation email to be able to download the Utils. Is there no way to get around that and have a completely from-scratch project?

    • @LeWoure
      @LeWoure 24 дні тому

      a method for getting the mouse position:
      private Vector3 GetMouseWorldPosition()
      {
      Vector3 mousePosition = Input.mousePosition;
      mousePosition.z = -Camera.main.transform.position.z;
      Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePosition);
      return worldPosition;
      }

  • @nickmao5969
    @nickmao5969 4 роки тому +2

    awesome! im gonna make a starcraft in unity now. (says a guy who just started learning unity)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому +2

      Go for it! Start small and do one tiny thing at a time!

  • @farvardinmainyu1961
    @farvardinmainyu1961 4 роки тому +1

    This video is very helpful, thank you Code Monkey.

  • @johnnyxp64
    @johnnyxp64 2 роки тому +9

    Still waiting a complete RTS series :(

  • @cardician23
    @cardician23 4 роки тому +1

    Just wanted to say your stuff is really good. Honestly it's better than Brackey's stuff.

  • @tigerpaw3106
    @tigerpaw3106 4 роки тому +1

    Question:What task manager should I use for my game?

  • @Judderplush
    @Judderplush 2 роки тому

    Please please make more RTS tutorials!

  • @userlink-12345
    @userlink-12345 4 роки тому +7

    Could you do a video on local avoidance, please?

  • @HexerMain
    @HexerMain 3 роки тому +1

    Awesome video brother!!
    Do you share the sprites in the downloadble files as well?

  • @rafcon9141
    @rafcon9141 4 роки тому +1

    Great video. I've played your top down shooter and I'd be cool if you do a video about how the turret works. Specially how to do the red lines closing and then shooting when closed.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      I covered the boss fight in detail here ua-cam.com/video/qZC1VYWnHZ8/v-deo.html
      The lines are just visual, there's a simple float storing an angle and its counting down, when its small it enters the shooting state

    • @rafcon9141
      @rafcon9141 4 роки тому

      @@CodeMonkeyUnity Thanks!

  • @jean-michel.houbre
    @jean-michel.houbre 4 роки тому +2

    Nice video. It is quite enjoyable to see the units move in 2D.
    However, I have a problem with moving to 3D. In your utilities, does the GetWorldMousePosition function work in 3D? Because I only get the coordinates of the camera, wherever I click.

    • @rawrrrz
      @rawrrrz 4 роки тому

      I'm having the same problem. I just switched my camera from Perspective to Orthographic, and use either WithZ, or change the 0'd .z to .y, hopefully this works, at least my coords now change between click and release.
      Edit: My results were off a bit, so now I'm just just doing a raycast, ScreenPointToRay(mousePos), and using hit.point. Seems more accurate when I get to selecting colliders, and also works fine in Perspective.

    • @jean-michel.houbre
      @jean-michel.houbre 4 роки тому

      Thank you. I found a RTS tutorial in 3D: ua-cam.com/play/PLm1w78-UUlMJ-S8Apf96YzzAaa2yfZzAx.html
      It's interesting, because the way of doing things is quite different, which allows you to learn something else.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому +1

      Yeah that function is made for 2D, in 3D you need to do a Raycast.
      You can download the project files for the Wash Your Hands game where I did make mouse interaction in a 3D world.
      ua-cam.com/video/q9pe-wH7eZ8/v-deo.html

    • @jean-michel.houbre
      @jean-michel.houbre 4 роки тому

      @@CodeMonkeyUnity thanks !
      I made a function GetWorldMousePosition3D which works, and which I already use to instantiate trees where I want during the game, but I came up against a problem with the selection area: changing the scale also modified startPosition.
      It was just a pivot problem to put on the bottom left, but what I did not know is that you must not only apply the changes to the texture, but also reload the sprite with the updated texture. So much time lost for a texture of 1 on 1 ^^.
      Great 2D tutorial, it works perfectly. Thank you !

  • @thedude110
    @thedude110 3 роки тому

    Awesome video as usual. But why are you not using a layer mask to check for collision instead of using GetComponent? I understand getting component is usually more expensive

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому +1

      Layers are used for tons of things like Rendering, Physics, so I don't like to use them to simply identify a type.
      But yes if you happen to have extreme performance issues in that one line then querying for the layer would be faster.

  • @pablocrespo8918
    @pablocrespo8918 3 роки тому

    very good tutorial! just one doubt ! IMovePosition and IMoveVelocity where do they come from or which video to have it as a reference? From already thank you very much !

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому +1

      I covered interfaces here ua-cam.com/video/MZOrGXk4XFI/v-deo.html
      And I used them pretty extensive in the Modular Character Controller ua-cam.com/video/mJRc9kLxFSk/v-deo.html
      With regards to this system it doesn't matter how they are implemented, as long as they do what they're supposed to do

  • @ulgmail
    @ulgmail 3 роки тому

    Great video, but wouldn't it be better to make the numbers of units and the distances dynamic and not hardcoded? What if I want to select 50 units?

  • @RicardoNecrofear
    @RicardoNecrofear 3 роки тому

    Hi Code Monkey.
    At 08:55, after I input the offset to the sprite, when I select the SelectionAre, the transform position arrows didn't snap to the lower left corner as In this example. Mine stayed in the middle.
    Do you have an idea as of why this may be happening?

    • @RicardoNecrofear
      @RicardoNecrofear 3 роки тому

      Nevermind! I noticed the selection box was being drawn correctly BUT behind the terrain sprite.
      Fixing it now!
      Loving the RTS tuts!

  • @alvyahmed7924
    @alvyahmed7924 3 роки тому

    Hey my selection area moves slightly towards my mouse when I drag it in any direction. I didn't change anything in the code

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

    Hi, I am planning on making an RTS game solo, and was wandering if your Utils package is ok with being used commerically? Thanks.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 місяці тому +1

      Yup feel free to use it in your projects, free or commercial. Best of luck with your game!

  • @dicktwisster3902
    @dicktwisster3902 4 роки тому

    It a good tutorial. At 15:47 to 15:52, the group is not moving at the most efficient route. For exemple, I notice some unit are taking long route to get to their destination. Like the unit from the far right ended up at the left side of the circle. Is there a way to decide their destination so that the group would reach to their destination faster rather than each unit take the shortest route to the destination?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      Sure just add some more logic to choose which unit goes to which position instead of just based on index

  • @ConradProteus
    @ConradProteus 3 роки тому

    I try to build a mix of rts + horror, you have any suggestions for this mix?

  • @Naeuuin
    @Naeuuin 4 роки тому +1

    I love your videos. Im making a mini RTS for a school final project and im trying to figure out how to do it where you see the UI multiselection ( like in StarCraft ) but I can only get 1 UI button to spawn or it keeps spawning indefinitely .
    do you have a tutorial on this or soon?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      You need to cycle through all the selected units and spawn a UI element for each of them.
      I very much want to continue doing more RTS videos so more coming soon!

    • @Naeuuin
      @Naeuuin 4 роки тому

      @@CodeMonkeyUnity i was doing that. My problem seems to have been that i was checking every frame instead of checking and populating after a selection

  • @quintongordon6024
    @quintongordon6024 2 роки тому

    Yep there we go

  • @peterpeperoni7102
    @peterpeperoni7102 4 роки тому

    I'd love to see more RTS tutorials, but why aren't you using a navmesh?

  • @anyidentifier
    @anyidentifier Рік тому +3

    Suggestion: you should make a video doing all the HUD logic of AOE and Warcraft 3. How to click in a unit and turn on some icons in the UI. In case of buildings, icons that spawn units when pressed and in case of units icons that uses skills or something else. All these functions applied to single unit and to multiple units if they're selected. And some icons that represents the selected units (like in Warcraft 3).

  • @NamHoang-cs3se
    @NamHoang-cs3se 4 роки тому

    Thanks! Hope you will upload some tut abour UI in near furture.

  • @Elnino2014
    @Elnino2014 4 роки тому

    Hey Codemonkey, i'm having trouble with creating enemy ai, i made Field of view which checks distande, angle and shoots ray in order to detect play (and sets visible = true), but is there any way something like OnRaycastExit? my ai behaviour is too simple patrol(if unvisible) - shoot (if visible). I want to add Searching state when player exits FOV.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      There's nothing built-in but sure that's easy to do, you store a boolean like isPlayerInFov, then you check the angle to the player, when it leaves you set the bool to false and fire off an event.

    • @Elnino2014
      @Elnino2014 4 роки тому

      @@CodeMonkeyUnity then enemy's initial state will be searching (since IsInFov = false), i want them to patrol and go to searching state for only 10 seconds only when player enters the Fov and Exits it

  • @xianchaencari3244
    @xianchaencari3244 3 роки тому

    Is there any way to add on a way for RTS units to attack a target (E.G Right clicking once selected on an enemy?) I've been trying to search through your videos but i can't seem to figure out a way to do this ^^; Great video though!!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      You just need to capture clicks on top of an enemy, add a Collider and do a Raycast
      I made some videos a long time ago that did that
      ua-cam.com/video/cxSkhlWAaqI/v-deo.html
      ua-cam.com/video/sb9jnpN9Chc/v-deo.html

  • @galacticnerds5276
    @galacticnerds5276 2 роки тому

    Hey, I'm making an RTS and there's a lot of architecture problems that I can't confidently understand. First of all, your UnitRTS class has a method for sprite activation, which I don't think makes sense considering the class should apply to enemy units which may not be selectable. Would it make sense for player and non-player units to have different prefabs with the UnitRTS component and a separate component for handling sprites and stuff for that prefab?
    Additionally, if you remove the Awake method from the unit class and give it a transform reference, you could change the code so that it doesn't have to inherit MonoBehaviour, which could allow the unit to move in the background when the GameObject is disabled. Is this a dumb idea?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 роки тому +1

      The goal in the video was Unit control so it wasn't meant for also controlling enemies, for enemies you probably don't want direct control so you could either have a generic script applied to both types or one script for each, depends on how many abilities are common to your friendlies/enemies.
      Sure you could make your whole game non-monobehaviour so the logic would not depend on any game object. That's exactly what I did in my Battle Royale Tycoon game. The game objects are only used for visual, all the logic is handled in regular C# classes.

  • @navysnow5618
    @navysnow5618 Рік тому

    Hey, love your channel been watching a lot recently. I have a question- do you think this type of movement would work in a mobile game well? If not any recremendations?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Рік тому

      I havent played any mobile RTS so not sure what are the best practices but sure this could work

  • @alexthebassist23
    @alexthebassist23 4 роки тому

    Just wondering, would it not be quicker to use layers to check if a unit is selectable, rather than checking for a script?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      Sure that's another valid approach, the performance wouldn't be an issue since it happens so rarely. If all of your Units are already set in their own layer that would work but in order to give them orders you need to get the component.

  • @dogstorm6814
    @dogstorm6814 3 роки тому +1

    Hey Code Monkey, I understand this tutorial but am getting an error for "IMovePosition" everything else in my scripts works fine but im stuck here. Any help would be greatly appreciated.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      What error? I covered interfaces in detail here ua-cam.com/video/MZOrGXk4XFI/v-deo.html

  • @johnnyu3287
    @johnnyu3287 Місяць тому

    Is there a video explaining how path finding was implemented ? I watched the A* one and it doesn't seem to work with multiple units correctly. You also mentioned flow field which I couldn't really make it work in my case where I want to store one unit in each cell of the grid

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Місяць тому

      I didn't implement pathfinding in this demo, it's really just dumb straight movement.
      Flow field is indeed the main option for RTS games with lots of units. You can still keep one unit in each grid position, you can check the next grid position for each unit based on the vector, and check if that one is empty or not.
      Or only check at the destination, when getting that point look for the closest empty grid position.

    • @johnnyu3287
      @johnnyu3287 Місяць тому

      ​@@CodeMonkeyUnitythe problem is most of the tutorials I came across seem to use physics raycast to handle units movement
      I tried to combine the grid system with the physics logic but it gives weird results.
      I'll give it another shot tho,
      Thank you so much!

  • @tonyclx
    @tonyclx 3 роки тому

    @Code Monkey I am getting this error when running the pathfinding script
    NullReferenceException: Object reference not set to an instance of an object
    MovePositionPathfinding.SetMovePosition (UnityEngine.Vector3 movePosition)
    (at Assets/_/Stuff/Videos/ModularCharacter/Scripts/MovePositionPathfinding.cs:24)
    UnitRTS.MoveTo (UnityEngine.Vector3 targetPosition) (at Assets/RTSControls/Scripts/UnitRTS.cs:21)
    GameRTSController.Update () (at Assets/RTSControls/Scripts/GameRTSController.cs:73)
    I cannot figure out this error. I have not made any changes to your code. Can you please help me? Thanks..

  • @arcday4281
    @arcday4281 4 роки тому

    Hi ! Very useful video. Tell me if there is anything in your videos about changing weapons in your hand, such as changing a sword, axe, or spear... (I want to understand how to better implement weapon changes in skeletal animation)???

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      Yeah that's going to be very dependent on what animation system you're using, I haven't covered the standard unity animator yet.
      I made the Ability Bar but its using my custom animation system ua-cam.com/video/obvUYZK-kGE/v-deo.html

    • @arcday4281
      @arcday4281 4 роки тому

      @@CodeMonkeyUnity Thank you very much for your responsiveness !

  • @memsose6907
    @memsose6907 Рік тому +1

    Thank you so much
    But you used overlabareall in physics2d
    What can I use instead of this in 3d?

  • @jackjones1345
    @jackjones1345 4 роки тому +1

    Can you make terraria like project? I create game like that but I can't make random generator and mining-building system

  • @stephenharvey5901
    @stephenharvey5901 3 роки тому

    Hey there! I'm using Visual Studio and Unity 2020.1 and when I type Vector3 all it gives me is "Vector32" in the selection box. All vector code is missing... is there something I've messed up? I didn't remove anything from the original startup either. All collections are being called, as normal.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      Vector3 is one of the base Unity structs so it seems like your Visual Studio isn't recognizing the UnityEngine namespace. Try manually installing Unity Tools for Visual Studio

    • @stephenharvey5901
      @stephenharvey5901 3 роки тому

      @@CodeMonkeyUnity I found it! Visual Studio wasn't selected for Unity's third party coding platform on my project. Once I went in and changed that, it started recognizing Unity's "using" platforms

  • @madmaxdx3326
    @madmaxdx3326 2 роки тому

    I want to ask you, is there a video that explains how the player jumps in (3D) a third-person shooter I need for my game, it's been two days, I'm looking for a jump that fits my game, but there are mistakes that happen to me, and your explanation is perfect and understandable, so I need your help, big brother

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 роки тому

      I made a Jump here ua-cam.com/video/DEGEEZmfTT0/v-deo.html
      It's in 2D but the logic is the same in 3D, just need to use 3D components instead.
      So do a Physics.Raycast instead of Physics2D.Raycast

  • @Dangerdave57
    @Dangerdave57 4 роки тому

    After adding the utils package I get an error but no idea where it's coming from. Any tutorial on how to use the utils package?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      What error? Each function/class in the utilities solves a specific problem so you just use what you need

  • @Matt-nm1lk
    @Matt-nm1lk 3 роки тому +1

    When I begin my game with two instances of the player prefab, for some reason the second one immediately begins to move towards the first. Anyone else run into this issue, or have some idea?
    edit: turns out they're actually getting sucked to the grid origin. I guess it must be the velocity, I usually just do raw input... who knows lol.

  • @Lozing
    @Lozing 4 роки тому

    I tried using your code for the different positions that the units go to so they don't overlap but i get the unity error ' the name 'positionList' does not exist in the current context' (for your line 90 as of 14:22 in the video), I am puzzled as to why this is happening, can you please help?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      It means you don't have any variable named "positionList"

    • @Lozing
      @Lozing 3 роки тому

      @@CodeMonkeyUnity Oh yeah, i just missed a line of code. Thanks!

  • @lordzombieboy
    @lordzombieboy 11 днів тому

    Does anyone know how to make it so that my troops don't go to a position in the formation that overlaps with other troops in the selection? Mine are in the shape of a pill/capsule right now, so they tend to overlap each other a lot, even if the distance is increased

  • @mrbenjiboy9527
    @mrbenjiboy9527 4 роки тому

    nice

  • @YoshiroPoh
    @YoshiroPoh 4 роки тому

    so does that mean only 30 units can be controller at one time with this script? since, at least from the codes, rather than dynamically, calculate what to place within the space, it's calculating position-based on area set beforehand. Unless I missed out something..

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому

      You can generate as many positions as you want to control an any number of units.
      I only generated as many as I needed but if you need more just calculate more

    • @YoshiroPoh
      @YoshiroPoh 4 роки тому

      @@CodeMonkeyUnity Ah Thanks. Just wanted to make sure I understand the code right.

  • @drafi0775
    @drafi0775 4 роки тому

    Hello , is there a way to easely get the mouse position for "currentMousePosition" rather than using a utils , i prefer not using them , thanks in advance

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому +2

      The function just does mainCamera.ScreenToWorldPoint(Input.mousePosition);

  • @johnnyxp64
    @johnnyxp64 4 роки тому +1

    question: why you don't initiate the lists for example in your code the moment in the same line you are declaring them? why go through the hassle to remember to do that in another state? 🙄

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому +2

      Just because I don't like that pattern, I like to separate declaration and initialization.
      Works the same though so if you prefer that pattern then by all means use it.

  • @loot6
    @loot6 3 роки тому

    So the target positions wouldn't take into account any blocked areas right?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 роки тому

      Correct, you would need to add that feature if you needed it. The implementation depends on how you are defining blocked areas.

  • @AdamCheong
    @AdamCheong 4 роки тому

    Should I test this out with 19.3.11f11 + Universal Render Pipeline or 2D ?

  • @Riio25
    @Riio25 Рік тому

    where do we get the assets or tutorial on how to get to where this video started?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Рік тому

      Each tutorial is on a specific topic. For example this one is on handling RTS controls but you can combine that with any number of visuals. The control system and the visuals are separate.
      The specific visuals that I'm using here is a custom animation system based on dynamically modifying meshes unitycodemonkey.com/video.php?v=11c9rWRotJ8
      Then the mouse works differently in 2D or 3D unitycodemonkey.com/video.php?v=0jTPKz3ga4w
      unitycodemonkey.com/video.php?v=3zxTigjJr24

  • @cksoba8850
    @cksoba8850 11 місяців тому

    im having some problems, it says "error CS0103:the name 'utilsclass' dose not exist in the current context" how to fix?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  11 місяців тому +1

      The name is UtilsClass and not utilsclass. Also those are my own utilities, not something built into Unity so they need to be in your project in order to use them

  • @beydeloso
    @beydeloso 4 роки тому

    Hey i have a question.
    How do you make the map or ground pls help me thank you

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому +1

      Its just a simple texture drawn in Photoshop

    • @AdamCheong
      @AdamCheong 4 роки тому +1

      grab a "seamless texture terrain" from google search and save as a PNG. then in unity assets - import new assets. change to texture type sprite type in inspector, mesh type full rect then drag it into the scene, on the instance that was created set draw mode to tiled and width and height to say 20 and 14 (that worked for the turbosquid texture I used)

  • @graybullet9395
    @graybullet9395 Рік тому

    When move the unit with the right mouse button, I want to make a script to stop move when it hit the wall, so I see the 'Modular Character System in Unity' video, and I add the script 'PlayerMovementMouse '.
    but it did not work and go through the wall.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  Рік тому

      You need to incorporate some kind of pathfinding system if you want it to avoid walls unitycodemonkey.com/video.php?v=alU04hvz6L4
      unitycodemonkey.com/video.php?v=46qZgd-T-hk

    • @graybullet9395
      @graybullet9395 Рік тому

      @@CodeMonkeyUnity Thank you for reply

  • @kushovu
    @kushovu 4 роки тому

    it is posible to implement this with some kind of path finding and obstacle avoidance??

    • @kushovu
      @kushovu 4 роки тому +1

      oh srry i got it, with the modular system there is a path find didnt?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 роки тому +1

      Yes, if you're using a modular character controller then it would be as simple as adding that module.
      If not then you just need to implement a call to your pathfinding system when you tell the unit to move and maybe also use pathfinding to validate unit positions

  • @Kornux
    @Kornux 3 роки тому

    2:32 I try to move the script and it says to me: "the script don't inherit a native class that can manage a script"

  • @TheJonBrant
    @TheJonBrant 3 роки тому

    If anyone's opening this up after some ECS updates and getting errors, here's some fixes:
    Time.deltaTime is now Time.DeltaTime
    World.Active.EntityManager is now World.DefaultGameObjectInjectionWorld.EntityManager
    This fixes the compile errors, now to figure out how to get the rest of it running

  • @OBG7208
    @OBG7208 2 роки тому

    When I play the scene, my units will automatically move to the center for no apparent reason, then after that, they work fine. How do I make it so that they stay where they are when I play the scene?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 роки тому +1

      On Start() set their target position to their current transform.position