How To DAMAGE Enemies in Unity

  Рет қаралды 45,828

BMo

BMo

Күн бұрын

Пікірлер
@tristanlapointe9087
@tristanlapointe9087 2 жыл бұрын
Wow thank you so much. I've never looked at basic stuff like this in such a complex yet modular and practical way. Great tutorial!
@T3QN1Q
@T3QN1Q 2 жыл бұрын
based on your other recent video, "the four gamer personality types" (great vid btw) I know I'm a killer so this is what I need!
@bacjam6139
@bacjam6139 2 жыл бұрын
Tutorials like this are life savers
@thenoglinman
@thenoglinman 2 жыл бұрын
I was just about to look for an enemy damage tutorial then got this notification!
@i_am_set
@i_am_set 2 жыл бұрын
You are easily one of my favorite Unity tutorial youtubers!
@michaelonuoha6548
@michaelonuoha6548 2 жыл бұрын
thank you sir you saved my entire life i havent slept since
@HunneProductions
@HunneProductions 2 жыл бұрын
For some reason "ToList()" in the GameManager script isnt working. Do you know why?
@taahaalbari
@taahaalbari Жыл бұрын
you are awesome! Thanks for the help & Great tutorial :D
@plutoniumbellamy1912
@plutoniumbellamy1912 2 жыл бұрын
Could you make a tutorial about an ammo collection system. Say, an ammo randomly drops after a certain event occurs, then when the player collects/collides with it - it serves as an ammo for a shooting system to the enemy(s). When the ammo counter is 0, then the play can't shoot, and so on. Thanks!
@Joriku
@Joriku 2 жыл бұрын
Thank you, took me hours to even get something to work. This got me able to shoot my current test enemy without issues
@GnuggetFPV
@GnuggetFPV 2 жыл бұрын
it says "'Enemy' does not contain a definition for 'TakeDamage' and no accessible extension method 'TakeDamage' accepting a first argument of type 'Enemy' could be found (are you missing a using directive or an assembly reference?)", even though I wrote all the code over four times!
@PhantomInTheNight19
@PhantomInTheNight19 2 жыл бұрын
THIS is what i was looking for thanks
@bladeprincess
@bladeprincess Жыл бұрын
7:14 should the invoke line really be after the Destroy line? how is it called if the enemy is immediately destroyed? im curious and this would really help me. thanks!
@bradleypetzer6802
@bradleypetzer6802 Жыл бұрын
I'm also new to this but I believe I read recently that the Destroy action doesn't happen immediately so you are still able to call lines for a period after the Destroy. something to do with frames or updates Hope this helps. from a noob learning :)
@torontogamestudio2991
@torontogamestudio2991 2 жыл бұрын
Can you make a tutorial on how the next scene will load after all enemies are killed?
@sharkao2686
@sharkao2686 2 жыл бұрын
private void Awake() { enemies = GameObject.FindObjectsOfType().ToList(); UpdateEnemiesLeftText(); } its giving me an error in the ToList() and the error says this Enemy[]' does not contain a definition for 'ToList' and no accessible extension method 'ToList' accepting a first argument of type 'Enemy[]' could be found (are you missing a using directive or an assembly reference?)
@supernovascotian
@supernovascotian 2 жыл бұрын
I'm not sure if this is wrong somehow, but adding "using System.Linq;" in the top of your script seems to solve this issue.
@cryptolotl
@cryptolotl 2 жыл бұрын
Tried adding the using System.Linq; but still get the same error. Also tried adding using UnityEngine.UI; but still shows up. Anyone else resolve the issue a different way, or has the System.Linq worked for everyone else?
@Moneybefehl
@Moneybefehl 2 жыл бұрын
@@cryptolotl im running into the same problem, ill update if i find a solution
@Moneybefehl
@Moneybefehl 2 жыл бұрын
@@cryptolotl so my solution is: private void Awake() { enemies = new List(); enemies.Add(GameObject.FindObjectOfType()); } we first instantiate enemies with an empty list of type Enemy and then add the Enemy object
@HunneProductions
@HunneProductions 2 жыл бұрын
it works
@siickale
@siickale 11 ай бұрын
thanks for the tutorial
@n11ckz64
@n11ckz64 2 жыл бұрын
Hey BMo! Can you make a tutorial about game mechanics like in "Move the block : Slide puzzle" game, please! There are no tutorials on this topic on the Internet. I will be very grateful if you make this tutorial!
@Stompin40
@Stompin40 2 жыл бұрын
Holy sh*t this was sick to see!
@tuxedobird8379
@tuxedobird8379 Жыл бұрын
i followed it but now y bullet just goes through everything i dont know what i did
@loozekh
@loozekh Жыл бұрын
same issue. if you find a fix please lmk update: go to your bullet prefab and disable istrigger on the collider, it'll work then
@6fukraken
@6fukraken Жыл бұрын
@@loozekh You have to add box collider (in the add component menu)
@LuanaSouza-fw1iz
@LuanaSouza-fw1iz 2 жыл бұрын
It was nice to see a mix of direct calling a function in an script and c# events on the same structure. Also, when I subscribe event's on the awake/enable function it seems like many of the events are called before they are created. That's why I subscribe on start lately. Did that ever happened to you? I find subscribing on enabled and unsubscribe on disabled elegant but couldn't do reliably
@BMoDev
@BMoDev 2 жыл бұрын
Yes, I know what youre talking about, it has to do with the order of scripts being executed - in which case the quick and dirty solution is the reorder things in your hierarchy, but you can specify which scripts execute first in the project settings menu, this way you create events first before subscribing
@fryptompt
@fryptompt 2 жыл бұрын
I Have an enemy prefab and i am spawning that enemy with prefab now i have health system but the health Value is common for all of the enemies clone , how can i make the health value individual for all the clones ?
@LesP56
@LesP56 2 жыл бұрын
How is this handled if the enemy is an instance of a prefab?
@BMoDev
@BMoDev 2 жыл бұрын
When you instantiate the prefab Start will get called, but you could create a FindTarget method and call that whenever you want or it will be called in Start if you put it there like the video. GameObject newEnemy = Instantiate(enemyPrefab); newEnemy.GetComponent().FindTarget();
@saishsawant7410
@saishsawant7410 2 жыл бұрын
wow , i was struggling with enemy destroy for so long., all the other videos were of no help ... i typed your code and a few tweak's and the code was working fine.
@DashzRight
@DashzRight Жыл бұрын
Why the collisionEnter function is used in the projectile and not in the enemy?
@eileeng2492
@eileeng2492 2 жыл бұрын
Who should I test this on first?
@travnutztv
@travnutztv 2 жыл бұрын
Lost me at the game manager part. not sure if my "using"s are correct cause you never showed the top of the script.
@monkeypwners
@monkeypwners 4 ай бұрын
My bullets go straight through my walls... I have a BoxCollider2D on the walls and on my bullet and none of them are set to "IsTrigger"... Please help
@zendraw3468
@zendraw3468 2 жыл бұрын
why did you make the event in the enemies and not in the gamemanager? it shuld be the other way around
@iken_ar
@iken_ar 2 жыл бұрын
Thanks !
@fluffystuff
@fluffystuff 2 жыл бұрын
bruh I've been scouring the internet for this damaging player and this is the only tutorial that my tiny brain can understand (bcz I'm a beginner)
@nickcapria817
@nickcapria817 2 жыл бұрын
.Count doesnt work for me any suggestions I get error CS0428
@MaestroMarc
@MaestroMarc 7 ай бұрын
It'd be neat if you made a 3D version of this tutorial!
@jooeyyjn
@jooeyyjn 6 күн бұрын
I used this for a 3d game. You do everything the same except wherever it says 2D, just don't put that.
@jrgvsgames5673
@jrgvsgames5673 2 жыл бұрын
So i followed everything correctly but when i shoot my enemy it doesnt die? any help please?
@BlueAndy_
@BlueAndy_ 2 жыл бұрын
Well it doesnt quite work for me, i try this exact code just in 3d and insted to check the TryGetComponent thing for an normal collison i look if my RayCast has hit an Enemy and then try to use the public TakeDamage Funcion. And it does work for the very original Enemy but not for the other clones, even if i hit the clones the original enemy dies all of the time. Idk what is wrong here really confussing.
@BlueAndy_
@BlueAndy_ 2 жыл бұрын
Nevermind got it working, the only thing that i really did was assign an empty GameObject in the script name gameObjectHit and then just assined the GameObject that im hitting to this empty hitgameObject. And then i did what he in the Video did //this is on top of the code GameObject gameObjectHit; // this is inside the if statement when the raycast hit something gameObjectHit = hitInfo.transform.gameObject; if(gameObjectHit.TryGetComponent(out HitDetection en)) { en.TakeDamage(damage); }
@WladylawGomulka
@WladylawGomulka Жыл бұрын
what if i have couple enemy prefabs each named diffrently?
@cank4286
@cank4286 2 жыл бұрын
C# static events FTW! Unity Events and messaging suck :( . Only issue is += -= syntax is weird and causes noisy code.
@kacperkucharski4470
@kacperkucharski4470 Ай бұрын
my enemy just flew away, why ...
@noside6817
@noside6817 2 жыл бұрын
ty king
@Unknownuncovered-NIKI7
@Unknownuncovered-NIKI7 9 ай бұрын
broo You forgot the bullet part!!!!
@ryanem969
@ryanem969 2 жыл бұрын
I've followed this tutorial from scratch, 3 times. My bullets do not "destroy" My bullets do no damage to enemy What could I be missing? EDIT: I had "OnCollision2D" not "OnCollisionEnter2D". Wow.
@6fukraken
@6fukraken Жыл бұрын
I have the same problem but i will just search other tutorial i guess
@ryanem969
@ryanem969 Жыл бұрын
@@6fukraken Oh, I was a noob. I'm not pro now but ask me anything.
@Neon-no8kv
@Neon-no8kv 2 жыл бұрын
could you use this script as a player script too BTW great tutorial!
@noahnyman4420
@noahnyman4420 2 жыл бұрын
My enemies die in 1 shot :/ update: I die in 1 shot :/
@qdnr
@qdnr 2 жыл бұрын
Спасибо
@eggseatpegs
@eggseatpegs 2 жыл бұрын
Yeet
@fongentripaloski
@fongentripaloski 2 жыл бұрын
I want to have a Level Complete text when the enemy counter reaches zero. How would I do that with your script? I tried the if statement but dunno what to put in the brackets ( )
@aarononeale7727
@aarononeale7727 Жыл бұрын
if (enemyCount
Flexible LOOT SYSTEM in Unity with Random Drop Rates
13:24
Why I am NOT Making These Enemies
17:06
Deynum Studio
Рет қаралды 215 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
2D PATHFINDING - Enemy AI in Unity
23:13
Brackeys
Рет қаралды 829 М.
Creating SMART enemies from scratch! | Devlog
5:40
Challacade
Рет қаралды 379 М.
Player Health System #1: Taking Damage (Unity Tutorial)
7:18
Night Run Studio
Рет қаралды 31 М.
Easy Ammo & Reloading System in Unity
7:48
BMo
Рет қаралды 11 М.
2D Enemy Shooting Unity Tutorial
12:52
MoreBBlakeyyy
Рет қаралды 63 М.
MELEE COMBAT in Unity
21:07
Brackeys
Рет қаралды 1,6 МЛН
I Made A Platformer Game But You're The Enemy
6:12
BMo
Рет қаралды 664 М.
Why I'm Moving To Godot In 2025
14:23
Acerola
Рет қаралды 180 М.
Enemy Health System #3: Dealing Damage to Enemies (Unity Tutorial)
8:33
Night Run Studio
Рет қаралды 10 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН