Simple Battle System in Unity (Spawn Enemy Waves, Trigger)
Вставка
- Опубліковано 18 вер 2024
- 🌍 Download Dashlane for FREE on your first device by clicking here bit.ly/3ayHh83 and automatically get a 30 day free trial of premium! No credit card required at signup!
✅ Get the Project Files and Utilities at unitycodemonke...
Let's make a Simple Battle System script to handle Spawning Enemy Waves with Events on Start and Finish.
This video is sponsored by Dashlane
I made a Top-Down Shooter in 7 Days!
unitycodemonke...
• I made a Top-Down Shoo...
Animated Sprite Outline - Shader Graph
• Sprite Outline (Animat...
Aim at Mouse
• Aim at Mouse in Unity ...
Persistent Particle System
• Persistent Particle Sy...
Simple Key Door System
• Simple Key Door System...
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 unitycodemonke...
📝 Get the Code Monkey Utilities at unitycodemonke...
#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: unitycodemonke...
- Twitter: / unitycodemonkey
- Facebook: / unitycodemonkey
Here's the Battle System I used in the Top-Down Shooter game, how would you expand upon it?
🌍 Get Dashlane for FREE on your first device by clicking here bit.ly/3ayHh83 and automatically get a 30 day free trial of premium! No credit card required at signup!
👍 Downloading the app helps support the channel!
Hi Code Monkey! Thanks for the tutorial! But I have the following question - I tried to download your package, but failed to load all the script, particularly the Enemy Archer script so that I could refer to the Spawn method. Does your package only run on certain Unity versions? Sorry for the trouble >.
Great job on the sponsor! I hope this will allow you to keep creating great content as always.
Thanks!
your tutorials are amazing, very comprehensive. also always making sure to teach clean code, not just quick code. so much to aspire to! keep it up
What's clean code? What are the benefits of such code.
I just want to say thanks, your tutorials are awesome, im currently working on a VR project and this helped a lot. Keep em coming !
Great Tutorial, in a few seconds i also learned alot about how state machines work :) Please keep up making good videos
Would a nice way to maintain the waves from the battle system be making a scriptable object for them (holding an array of enemies' transforms and spawn time) and then assigning waves 1,2,3 to the array of waves on the system?
Yup exactly, using a scriptable object instead of a simple array would be a great way to simplify the inputs as well as easily add more optional complexity to your spawning logic.
Good evening,
I have been watching this video and number of other ones, trying to get a good start on a build of the battle system you have designed here, this is all very impressive!
The issue I am encountering is finding the start. In the video above, you gloss over the EnemySpawn script and the Spawn() function is mentioned, but never opened up. What video would I need to start with to really build this system from the ground up?
What you have here is very much in line with what I want, I am working on a spawn system like that in the original Legend of Zelda, so that when you walk on screen, the enemies spawn, leave it, they are removed.
It just calls Instantiate(enemyPrefab); which then plays the shader effect before enabling their AI.
A bit late but yeah, I had the same doubt, I downloaded Code Monkey's unitypackage file and checked, it was a simple SetActive function, to enable the gameobject, inside a public function, so that it could be called from outside even when the gameobject was disabled. Quite clever, Thanks CodeMonkey, the tutorial really helped!
Can you made tutorial for 3D games
_ Bosko4Pro _ Hi, I’ll be covering 3D game tutorial .. I’ll be really happy if i can get some support :))
Man you are a legend.
Nice system. I love events!
Awesome Stuff as always Code Monkey :)
I am surprised that you are not using DOTS more regularly. Do you see it as just additional complexity for these tutorials, or are you seeing it not perform as well? Just curious?
Of course, you ARE be the leading edge on DOTS tutorials. So I understand, its a bit harder :)
Calling it a "Battle System" got me all excited... :P
Cheers!
Micah
I try to mix them both, I love DOTS but normal game objects aren't going anywhere so there's still lots of topics I'd like to cover. Currently working on DOTS Pathfinding so over time I will remake a bunch of systems in DOTS
where is spawn script?
I don’t know if you take suggestions but Could you do a system for gun variants like a system for guns with different stats
@CodeMonkeyUnity How did you make the "Charger Enemy" in this video, can you Make a 3D Tutorial on it Because I really want to have a Charger Enemy in my game but there are no tutorials on how to make one
Hey I created a shooting enemy and I tried to put multiple of them in the scene and they mess with each other especially when I disable/kill one of them
how do I keep this from happening
Why didnt you show the Spawn method in you enemies?
How my specific enemy works isn't relevant to the Battle System logic, your enemies will certainly have some logic specific to your own game, it can be as simple as instantiating a prefab or more complex.
I know this is late but will this work with 3d games as well?
Yes, just swap sprites for 3D meshes, and maybe change the logic from XY to XZ
@@CodeMonkeyUnity K Thanks
Good job
I love your projects, would you have something teaching a quest system? attack as in WoW, where he marks the animal he attacks alone, would there be anything? and thank you I learn a lot with your videos, success
I haven't done a system to manage Quests but I have done the visual pointing to a target ua-cam.com/video/dHzeHh-3bp4/v-deo.html
Hello, thank you very much, I would have something or could teach you how to make this game mechanic like DDTANK, where we put strength, and show the angle and try to hit the other, I lowered your bird with an example of strength, more to the angle how to show or appear a marker on the screen where the shot can go, other types of shots, here’s the suggestion, today I’ll download more examples for studies, thanks
Great video! I have 1 question how do you prevent that enemies wont spawn in objects in levels. In my game they get stuck at stone or other stuff
Reeeaaaally really nice, #thanks ! :)
Hi Hugi, how do you suggest to make enemy AI for games? I know FSM's but A) I don't know a good implementation in Unity that is not too complicated (and hopefully has visual diagrams) and B) Be extensible to let me make and iterate enemies fast. Thanks!
I covered a simple AI System here ua-cam.com/video/db0KWYaWfeM/v-deo.html
Everything I've done in all my games is just expanded upon that
5:38 is so funny to me
I am curious, and hopefully you or anyone else can answer the question, but what is the difference between Private and Public void in the function? I have seen several tutorials on various aspects of scripting mechanics for a game and I am unclear as to the purpose of one over the other?
private means that function/field can only be accessed from that same class.
public means any class in your entire codebase can access it
Clutch at 15:45
Hi dude! fantastic tutorial! been looking into getting into event handling... one issue i have and i cant seem to get my head around is that when you place your Array. you are able to select different enemys . i realised that they are of the same type (enemy spawn), how is it that you make that three different types enemys are accesable from the same script?
Either use Interfaces or a Base class that they all share.
When I will start game development to which I will make game firstly 2d or 3d
Also when making a 3D game you have to worry about modelling, texturing and lighting where as with a 2d game you can just draw the graphics in photoshop or something similar
Thank you for your suggestions guys
Yes unless you are already very experienced at 3D Modelling and Texturing then sticking with 2D will be easier
i wanted to know how does this spawn system works, i'm working on a space shooter game, similar to games like R-type, and upon seeing how the enemies start hidden and then actually spawn i thought it could work for me
It just instantiating the prefab. You mean hte visual? It's a dissolve shader ua-cam.com/video/auglNRLM944/v-deo.html
So my question is kinda weird but could you use this to make like a spawn system where the player has to kill like a Key amount of enemies on a mission? Like make your wave system and add more then enough for the player to get the mission ending code?
Sure, this system is just a base, you can add whatever logic you want on top of it
Hello,
If the timer in the second wave is still counting and all the enemies in the first wave are dead, how can I automatically make the second wave spawn enemies so that the player doesn’t keep waiting.
Keep track of when hte enemies die and add a function on the battle system to manually force start the next wave
@ codemonkey is there a was of spawning enemies without turning the enemies in to a prefab, I actually made the enemy ai from the enemy ai video, and if I make the enemy component to a prefab all my references are rendered useless, dont know why
You're probably losing references because you're trying to reference something in the scene, you cannot do that since the prefab can be instantiated in any scene.
Structure your logic in such a way that either the prefab has all references as other objects or make your script grab those references when it initializes.
@@CodeMonkeyUnity I am not understanding what u mean
If instead of a timer to spawn the next wave, I wanted to check if the previous wave's enemies had all been killed, what should I use to check for that?
Keep a list of all the enemies and when one of them dies go through the list and see if all are dead.
@@CodeMonkeyUnity Thank you for the reply but I'm not sure how to apply that in the foreach loop that spawns the next wave. Would I be creating a list of Waves that remove themselves from that list when all the enemies in that wave return dead, stopping the loop when >1 wave is active?
Ah I found a much better solution while going through that
foreach (Wave wave in waveArray)
{
wave.Update();
if (wave.IsWaveOver()) continue;
else break;
}
@@jv9ufxcy Could u please show mevyour entire code. I'm trying to do the same thing.
video is good, but just too hard to follow everything, you make all parts so hard to trace ~~~by watching this video, i dont know where to get EventHandle, and how Player player = collider.getcomponent(); , its just feel like everything havent say before suddenly appear and that makes the video very hard to follow up.
by looking back other video will make it easier but , may be get some time to clear up the video list and make it like part 1 , 2 , 3 , 4 to make people who watch the video easier to follow and trace what they are doing.
no offense by the way, its always so happy to watch your video and learn a lot from it. it just something about managing video , just like your code is well managed , but not the videos:)
EventHandler is a standard C# class, if you don't know about events watch this video ua-cam.com/video/OuZrhykVytg/v-deo.html
GetComponent(); is how you get a component in Unity, if you don't know about that then it sounds like you need to learn the absolute basics first before attempting to do a more complex system like this one ua-cam.com/video/E6A4WvsDeLE/v-deo.html
Don't worry about how long it takes you or how much you need to rewatch something, that's all part of the learning process so just focus on learning and keep at it!
@@CodeMonkeyUnity nice!! thank you for that, and which video is talking about how to make character from sprite ? i cant find any, most video already has character set up.
Can you please recommande some books for unity C# programmation
The books that I recommend aren't strictly about C#, check out Clean Code and Code Complete
ua-cam.com/video/Vlcop0uxFIQ/v-deo.html
Hey dude you can do a MOBA game like lol offline or online, you know if you see this please do that video if you want :D bye
4:47 How to know to add those codes in that archer or any enemy becouse i am new.. sry
Can you make a enemy that spawn more enemy ?
Sure, you can do whatever logic you want. In that case just instantiate an enemy prefab when one dies.
Dashlane: SECURITY!!!!
Dashlane: Compromises someones full CC info
Hope it's fake lol
Are you saying Dashlane compromised someones CC info? Where did you hear that? I've done extensive research and found no such thing, it would take the lifetime of the universe to decrypt their data.
@@CodeMonkeyUnity lol c'mon it's in video 1:58
Hoping it's fake, but who knows..;)