Let's make some simple Tower Defense AI. Place towers and Fire Projectiles at Enemies in range! 🌍 Go to admix.in/ and Start Earning Revenue in under 24 hours! 👍 Using the tool helps support the channel!
@arturkaczan17764 жыл бұрын
"HTTP ERROR 500" when I want to download project files.
@CodeMonkeyUnity4 жыл бұрын
@@arturkaczan1776 Where are you seeing that?
@arturkaczan17764 жыл бұрын
@@CodeMonkeyUnity in Chrome, now information about becoming patreon is loading. Some hours ago, Chrome displayed only error :)
@jonathanboiragee33473 жыл бұрын
how should I make this work in 3d? (edit) for mistaken spelling.
@aybaksamiz63764 жыл бұрын
Code monkeys: types fast My brain: loading terrain
@zenmasters_games4 жыл бұрын
I was just wondering about a tower defense game. Just in time man, your content and tutorials are the best
@Distortion39334 жыл бұрын
Long-time lurker, just wanted to say I really appreciate you making all this information public. Really great guides and easy to follow.
@CodeMonkeyUnity4 жыл бұрын
Awesome! Glad you like the videos!
@mozzaStick054 жыл бұрын
I think adding some animations to the tower will make it feel more alive, anyways that cool!
@PeterMilko4 жыл бұрын
AI is such a pain when it gets more complicated. Im using behavior trees for Dwerve my tower defense dungeon crawler.
@MechabitGames4 жыл бұрын
Dwerve looks cool
@PeterMilko4 жыл бұрын
@@MechabitGames thanks, you can wishlist it on steam :)
@saadahmad57754 жыл бұрын
Your programming skills just blows my mind. I am kind of new to unity and C# and most of the time your code goes over my head. Can you tell me how to be good at it?
@CodeMonkeyUnity4 жыл бұрын
The answer is experience, I've been writing code for over 20 years now and working with Unity for almost 10, just keep at it, write some code every single day.
@saadahmad57754 жыл бұрын
@@CodeMonkeyUnity Thank you.
@MatthiasKrijgsman4 жыл бұрын
I'm really sorry for your eyes if you always use the Light Theme for coding. Great video, love them
@CodeMonkeyUnity4 жыл бұрын
Dark theme is the one that burns my eyes, light feels very comfortable.
@Hello-qg4yk4 жыл бұрын
Lol ok
@mrteadie4 жыл бұрын
That depends on how light your surrounding is.
@JovsValorant4 жыл бұрын
Hello the great monkey coder. Please create more tutorials about tower defense, a lot of your viewers are looking forward to it. I subscribed !!
@AADY3 жыл бұрын
The tutorial is awesome, and your voice is cool.
@sekker2k4464 жыл бұрын
Nice as always!
@joachimlaviolette70704 жыл бұрын
Great vid as always! But what if your enemies were moving faster? Since your tower shoots an arrow at the same speed from one position, the enemies could avoid all arrows if you reduced your collision radius for example as well as your arrows motion speed. Some months ago I was working on a same project with a radar able to shoot incoming targets in a given range (each target having a constant speed but not the same from one to another). I had this challenge of predicting the target position I should shoot at to be sure to hit the target, according to its speed and the speed of my bullets as well (considering that my bullets were following the pointed direction and the targets were moving linearly in a one same direction).
@CodeMonkeyUnity4 жыл бұрын
In the video I made the arrows follow the enemy position every frame so they work like guided missiles. You could predict the position of the enemy using their speed, move direction, arrow speed and distance but again that depends on what type of design you're going for. That approach only makes sense if you want your arrows to be physical
@tigransahakyan28404 жыл бұрын
Great as always
@maxdart4 жыл бұрын
Great video man!
@niclasandreasen6394 жыл бұрын
Make 3D Tower defence tutorial soon. Everything you make is 2D Feeling left out
@CodeMonkeyUnity4 жыл бұрын
Most of the things I make work both in 2D and 3D kzbin.info/www/bejne/aavbhZydn6-laJY
@niclasandreasen6394 жыл бұрын
@@CodeMonkeyUnity haha i fucking love u man :D Been spending the last 3 weeks just learning all your videos. I am extremely interested in the A* Pathfinding for entitys. The only issue i have is getting the animator component with my entitys. And i simply can figure out how to get around this. Just watch a video where some guy have the old animator on and entity but i could not figure out how it was made. I only build in 3D worlds that is why im lost. Any advice or help would really help guide me to a solution. Take care and please continue making awesome videos.
@bsen22674 жыл бұрын
Thank you Code Monkey
@Drakkon3 жыл бұрын
how do i run it once i download it
@LuminfalVids4 жыл бұрын
Help please! Getting the upgrade to work through the button sprite script isnt working. It is all coded the same, but when I click the button, the function to upgrade is never called.
@CodeMonkeyUnity4 жыл бұрын
Add a Debug.Log to verify the button is capturing the click kzbin.info/www/bejne/a5rVp2ZmYseHgNk
@Patte0133 жыл бұрын
Hi Code Monkey! Thank you so much for this video, it has helped me a bunch so far. I do wonder though if you've got a tip on how to make it impossible for the player to place a tower on one or more specific "grid-tiles" as well as not being able to place another tower on top of one that's already there with this grid-system. I've been scratching my head for a couple of hours regarding this. Thanks!
@CodeMonkeyUnity3 жыл бұрын
The underlying Grid System is the one that I made from scratch in other videos kzbin.info/www/bejne/rZKopHqrYpJshpo kzbin.info/www/bejne/bpvVcoqqfp2Fjsk Essentially each Grid position has it's own object so you can easily add a simple boolean "canBuild" or "isOccupied" and check that before building.
@Patte0133 жыл бұрын
@@CodeMonkeyUnity Yeah I figured it would be something along those lines. I sucessfully made it impossible to place towers on top of towers but what actually confuses me is making sure that the player isn't able to place towers on the path which the enemies will walk on from the getgo. I'm unable to figure out how that code would look like. While I'm at it is there a way of checking that the player actually is clicking on the grid and not beside it? Since in my game right now you're able to place towers wherever you feel like but they will always be placed in a grid-like manner. Thank you for the quick reply as well. You're truly a life saver!
@CodeMonkeyUnity3 жыл бұрын
@@Patte013 You could save the buildable state in some file or a Scriptable Object. Create it like on grid position, 0,0; buildable = false; 1,1: buildable = true; and so on Then read that file and apply that data when you create the Grid in runtime.
@avalancherelapse3 жыл бұрын
for some reason, this video doesn't show up on your channel under "videos"!
@newbiegamer97454 жыл бұрын
How to spawn enemy at same time with different spawning points
@In-N-Out3334 жыл бұрын
Is the reason certain functions are marked as static because they don't read or write to any member variables?
@jasiek5114 жыл бұрын
Static means it belongs to the class and not an object. A static method cannot operate on instance variables, only on static variables (belonging to the class, shared among all instances). It's mainly used to have a method that is only relevant to that class in that class without having to create a new instance to access it.
@CodeMonkeyUnity4 жыл бұрын
Static means the function is on the class on not on an object instance, so I don't have to have a ProjectileArrow instance in order to call the Create() function. You could make it not static but that wouldn't make much sense since you would need an instance of a ProjectileArrow in order to spawn more ProjectileArrows.
@In-N-Out3334 жыл бұрын
@@CodeMonkeyUnity But at 6:26, you declared the Create function as private, so even if you did create an instance of ProjectileArrow, you still wouldn't be able to access that function from another class. I thought you marked it as static because it wasn't reading or writing to any member variables.
@CodeMonkeyUnity4 жыл бұрын
@@In-N-Out333 Yes it needs to be public, I changed it at 7:20, it's just a habit of writing private by default.
@mstfyilmazer3 жыл бұрын
Hello, I have a question about RefreshRangeVisual@UpgradeOverlay, I am currently developing a 3d tower defense, and range visual algorithm generally acting wrong on my game. I changed 2f multiplier from tower to tower. But couldnt find a proper solution for every tower acting at least similar range visual. Can it be about transform position or tower transform scales difference? Can you help me please?
@sonicherores4 жыл бұрын
I am having a small problem with the placing of towers I can place them in the box but they also seem to be able to be placed on the outside is it something with the ValidateWorldGridPosition? or would the problem lie with my actual grid the grid code is the same as used in the Grid video for generics :) So I am not sure where the problem lies Maybe its the debug visual being shown different while the grid is on screen the grid always shows on my Canvas UI and not on the game scene its on the location where the canvas starts.
@Marco.Rangel4 жыл бұрын
Same Problem:/
@p1ayer0ne474 жыл бұрын
you posted this comment a month ago so this is probably useless now but if it helps anyone who has this problem and searches the comments this is what fixed this problem for me, i aded the instantiate inside an if statement that checks whether the tile is null (space outside the grid is null): private void SpawnTower() { Vector3 spawnPosition = UtilsClass.GetMouseWorldPosition(); spawnPosition = ValidateWorldGridPosition(spawnPosition); spawnPosition += new Vector3(1, 1, 0) * grid.GetCellSize() * 0.5f; if (grid.GetGridObject(spawnPosition) != null) { Instantiate(GameAssets.i.pfTower1, spawnPosition, Quaternion.identity); } }
@shahwaiznaveed32904 жыл бұрын
i want to watch all of your videos related to this tower defense game... but I don't know which is the starting video and which is the last.... Can someone tell me?
@Marco.Rangel4 жыл бұрын
Nice video! I have a question, where is the grip file for edit the scale and add more squares??
@CodeMonkeyUnity4 жыл бұрын
The Grid System was fully created here kzbin.info/aero/PLzDRvYVwl53uhO8yhqxcyjDImRjO9W722
@jonathanfelipe13884 жыл бұрын
The assets that you're using, you who made it? If that's the case, how....HOW can you be a good programmer AND make pretty awesome art? Seriously, i can barely draw a single line in pixel art.
@CodeMonkeyUnity4 жыл бұрын
Heh no I'm not much of an artist, I drew the minions, the background and the arrows but the really nice looking tower was made by a proper artist for Hyper Knights.
@pragatidhanawade68114 жыл бұрын
hey!! can you tell a code for "do not show this window again" in unity im using panels to display the window . I want to add the option but i have no clue how to do it i tried doing it by changing its layer through code but it was so confusing . im using a toogle component for it
@CodeMonkeyUnity4 жыл бұрын
Essentially that's just a boolean that you want to save, easiest with PlayerPrefs kzbin.info/aero/PLzDRvYVwl53vRrMuPBkNNZUmnl1jCHcHs
@rayxr3 жыл бұрын
How do you prevent building on the enemy trail?
@CodeMonkeyUnity3 жыл бұрын
Depends on how you handle your build area, if you use a Grid System like this one kzbin.info/www/bejne/mqbPoKZ-hdFraKM Then it's pretty trivial to make certain areas buildable and others not buildable.
@waguno4 жыл бұрын
thank you.
@IINEXUSGAMERII3 жыл бұрын
Not sure if you'll see this but where is the code of ValidateWorldGridPosition. I've watched both the grid videos and this video and can't seem to find it.
@CodeMonkeyUnity3 жыл бұрын
It's been a while but I believe it just converts world position into a grid position and then checks if its > 0 and below width/height You can download the project files to see the source code
@kawaii_neko_013 жыл бұрын
Hey, code monkey, I really wanna add an infantry tower to spawn knight for my tower defence game, but I have no clue on how to do that. Do you think you can make a tutorial on that?? Love your work.
@paxel1210 Жыл бұрын
if i use Destroy(gameobject) in case of enemy, do i need to manually remove the object from the list?
@paulblart73783 ай бұрын
Very late but yes, you do. Destroy() will set the list's reference to the enemy to null, but won't delete the element from the list. If you don't manually remove the enemy before destroying it, you might get null reference exceptions.
@make-a-game-com4 жыл бұрын
Perfect, thx!
@lildgamedev6885 Жыл бұрын
Great video!! Iv'e got everything working but Id like a more practical way of closing the UI than having to click a button. This should simply be an onMouseExit() event but the colliders on the upgrade buttons interfere with that. Anybody know a possible fix or solution to this?
@CodeMonkeyUnity Жыл бұрын
Maybe after the UI is visible you could calculate the distance to the mouse, if too far close the UI
@lildgamedev6885 Жыл бұрын
@@CodeMonkeyUnity Thanks for the reply monkey, doesn't seem like the most elegant solution but thats what i ended up going with as well
@mindbdsm90364 жыл бұрын
I am running into some issues with importing project, version 2019.3.1f1 of Unity. The package is missing the ground sprite, grass? Other things I noticed, which are not such big issue, probably didn't think of them not to make video too long, you never check if the grid already has a tower so you can build infinite towers on same cell, also you can build on path as well. And if you build one tower above other, the above one is over the bottom one, which isn't correct :P Maybe ideas for next video in the TD series :D
@CodeMonkeyUnity4 жыл бұрын
I got the grass sprite from the Asset Store so I'm not allowed to distribute it. Yeah I just covered the absolute basics, you can expand upon it by making sure a single tower in a single grid position, adding more tower and enemy types, different routes, etc.
@awadawadomer22684 жыл бұрын
how change textures (background , character, .....) to HD (cleear) and we want put the camera with these textures thank you .......................
@3Katapa2 жыл бұрын
Hi, I Imported the Project files but what i was looking for wasnt in there. Im just not understanding the 'enemy.GetPosition()' 12:04 lines 35, 39. Would really love to see that code.
@CodeMonkeyUnity2 жыл бұрын
It just returns the transform.position
@3Katapa2 жыл бұрын
@@CodeMonkeyUnity Damn well that means i clearly don't understand as much as i think lol
@CodeMonkeyUnity2 жыл бұрын
@@3Katapa That's okay, learning is a lifelong continuous process, I've been programming for 20 years and I'm still learning new things
@chaimau21144 жыл бұрын
awesome!
@shahwaiznaveed32904 жыл бұрын
where are all the videos related to this project. could someone please give me the link from start to end.. you should have added all the videos of this project to a playlist
@CodeMonkeyUnity4 жыл бұрын
This is a standalone video, it's not part of any larger project. I have covered lots of other topics before like the character movement, spawning projectiles, enemy AI etc.
@neun92872 жыл бұрын
Hey CodeMonkey, I don't know how I should write the Isdead function at 12:08 (line 34). I would love to see the enemy code, but I can't find the script.
@CodeMonkeyUnity2 жыл бұрын
You can use whatever health system you want, for example you can use my own unitycodemonkey.com/video.php?v=tf8NhUgORQg
@marksmithcollins4 жыл бұрын
Suffering unity dots package conflict... every burst package versions after 1.1.2 does not compiles with entities package 0.5.1. Can you guide your package manifest versions list currently using with recent tutorials?
@CodeMonkeyUnity4 жыл бұрын
On the Pathfinding Game Objects video I used Burst 1.2.1, Entities 0.5.1 and Jobs 0.2.4
@marksmithcollins4 жыл бұрын
@@CodeMonkeyUnity Thank you!
@vladimirbrezniceanu20154 жыл бұрын
Hey man can you make a video explaining how to randomly generate objects?I mean one by one for example when one enemy is killed to randomly spawn another
@CodeMonkeyUnity4 жыл бұрын
That depends a lot on what specific design you're trying to create, it can be as simple as having a Enemy Spawner listen to a OnEnemyDied event and when that happens Instantiate the enemy prefab and give him a random position.
@arturkaczan17764 жыл бұрын
Hello @Code Monkey, I have some problems with Project files, in newest version Unity, and also in exacly the same version as in video tutorial. Is there simply solution? Maybe download older version Unity than 2019.3.06f? "Assets\_\Stuff\Videos\Inventory\Scripts\ItemWorld.cs(4,42): error CS0234: The type or namespace name 'Universal' does not exist in the namespace 'UnityEngine.Experimental.Rendering' (are you missing an assembly reference?) " "Assets\_\Stuff\Videos\TopDownShooter\Scripts\EnableLights.cs(16,42): error CS0234: The type or namespace name 'Universal' does not exist in the namespace 'UnityEngine.Experimental.Rendering' (are you missing an assembly reference?)" "Assets\_\Stuff\Videos\TopDownShooter\Scripts\Player.cs(17,42): error CS0234: The type or namespace name 'LWRP' does not exist in the namespace 'UnityEngine.Experimental.Rendering' (are you missing an assembly reference?)" "Assets\_\Stuff\Videos\Inventory\Scripts\ItemWorld.cs(29,13): error CS0246: The type or namespace name 'Light2D' could not be found (are you missing a using directive or an assembly reference?)" "Assets\_\Stuff\Videos\TopDownShooter\Scripts\EnableLights.cs(24,30): error CS0246: The type or namespace name 'Light2D' could not be found (are you missing a using directive or an assembly reference?)"
@CodeMonkeyUnity4 жыл бұрын
You need to install the Universal RP package
@arturkaczan17764 жыл бұрын
@@CodeMonkeyUnity You are awesome, it's working. One more thing, I don't see flying bodies, only blood particles. Do you know what to do with that? I have 4 warnings "The referenced script (Unknown) on this Behaviour is missing!" "The referenced script on this Behaviour (Game Object 'Main Camera') is missing! " "The referenced script (Unknown) on this Behaviour is missing!" "The referenced script on this Behaviour (Game Object 'PostProcessingVolume') is missing!"
@MiroWatchalong3 жыл бұрын
8:05 error - the object you want to instantiate is null
@CodeMonkeyUnity3 жыл бұрын
Sounds like you're calling Instantiate(); and passing in null as a parameter
@MiroWatchalong3 жыл бұрын
@@CodeMonkeyUnity I dont understand how can i fix it
@danlion3334 жыл бұрын
ArgumentException: The Object you want to instantiate is null.I have got this kind of error when trying to instantiate an arrow prefab.Been trying to fix it for couple of hours.Pls help.Thanks ;)
@CodeMonkeyUnity4 жыл бұрын
You forgot to drag a reference, you're doing Instantiate(null) somewhere Use Debug.Log to figure out what is null
@Marco.Rangel4 жыл бұрын
@@CodeMonkeyUnity I Have the same problem:/ I can't fix it
@wollywogholder33133 жыл бұрын
could you please do this for visual scripting? I wouldn't mind if it isn't on your channel since I bought your Udemy tutorials
@CodeMonkeyUnity3 жыл бұрын
That would be a massive amount of work so it's not something I'm planning to do but if you've gone through my VS course then you have enough knowledge to be able to convert this course to VS. If you use Programmer Naming all the nodes are named just like the C# commands.
@ing324 жыл бұрын
Could I download your Utils file? It would save me a lot of time since I'm new to unity and I want to learn new stuff.
@ing324 жыл бұрын
Oh nvm found out how. thanks !!
@CodeMonkeyUnity4 жыл бұрын
You can download it from the website
@ing324 жыл бұрын
@@CodeMonkeyUnity yup ty very much.
@СергейФёдоров-щ8ш4 жыл бұрын
Spasibo ) Please explain, how to made water/metal effects on grid area (not square - graph) via shaders (like in Oxygen Not Included).
@alexw93094 жыл бұрын
I used this tutorial for my 2d jump n run its in c# but for xna/monogame But the theory is the same gamedevelopment.tutsplus.com/tutorials/make-a-splash-with-dynamic-2d-water-effects--gamedev-236
@СергейФёдоров-щ8ш4 жыл бұрын
@@alexw9309 , i mean, how to texturing non square area on grid with one big texture (in ONY this is perfect to see, for examples metals, dirt, etc). I see this water tutorial before, it explain only top of water. p.s. 3 days later, solution found here - kzbin.info/www/bejne/j4Ssf2R-j9iad80
@beunique50504 жыл бұрын
Good bro
@AhmedMohamed-zj1qc3 жыл бұрын
Please make ur videos more beginner friendly 😃
@CodeMonkeyUnity3 жыл бұрын
It all depends on the topic, I have very beginner friendly videos and more advanced ones. Making a simple AI Tower Defense is pretty beginner though, you just need to know C# basics kzbin.info/www/bejne/f3fEqoSfpKxqZ6M
@AhmedMohamed-zj1qc3 жыл бұрын
@@CodeMonkeyUnity ok thank u
@avalancherelapse3 жыл бұрын
why not just use an array for enemies instead of a list?
@CodeMonkeyUnity3 жыл бұрын
Same thing, Lists are just easier to work with
@avalancherelapse3 жыл бұрын
@@CodeMonkeyUnity got it, thanks
@WanP1su2 жыл бұрын
list is more flexible, you can add new enemy in list when spawn and delete it when you kill
@Aguyfrom2254 жыл бұрын
I've only been following you for about 2 months. Wish I sub to you before. However; I am working on my game. It is tiring. I need incentive to keep working. Is there anyway you can advise or encourage me to keep going. Btw this 10 minute video took me all day to make. Well make is a little extreme.
@CodeMonkeyUnity4 жыл бұрын
The best advice is simply keep at it, don't rely on motivation, instead rely on self disipline, do something every single day even if its just 10 minutes. Best of luck!
@Aguyfrom2254 жыл бұрын
@@CodeMonkeyUnity thanks man! You are awesome
@zaenlol4 жыл бұрын
how did u create the environemnt ??
@CodeMonkeyUnity4 жыл бұрын
Its just a large texture
@muzammilabbasi89334 жыл бұрын
When will you start your new game project
@CodeMonkeyUnity4 жыл бұрын
Not sure, right now focused 100% on the videos. But when I do I'll make sure to do a Dev Log series going through the entire process
@milesonly.26084 жыл бұрын
Sound like new kermit voice
@CodeMonkeyUnity4 жыл бұрын
Is that good or bad?
@milesonly.26084 жыл бұрын
Just one more comment, but it really doesn't sound bad
@playzenderboy65844 жыл бұрын
Code Monkey please I have a question.
@paulblart7378 Жыл бұрын
do you still have a question
@awadawadomer22684 жыл бұрын
pls cheak your project error
@awadawadomer22684 жыл бұрын
problem download project !!?
@CodeMonkeyUnity4 жыл бұрын
What problem?
@awadawadomer22684 жыл бұрын
@@CodeMonkeyUnity stop download aftar 1 min and i try that with torrnet (error) >>??
@mhdidiab70564 жыл бұрын
Tank you How working on android
@mxitermi76014 жыл бұрын
Can you please make a Third person Controller? In 3D ^^