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!
@T3QN1Q2 жыл бұрын
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!
@bacjam61392 жыл бұрын
Tutorials like this are life savers
@thenoglinman2 жыл бұрын
I was just about to look for an enemy damage tutorial then got this notification!
@i_am_set2 жыл бұрын
You are easily one of my favorite Unity tutorial youtubers!
@michaelonuoha65482 жыл бұрын
thank you sir you saved my entire life i havent slept since
@HunneProductions2 жыл бұрын
For some reason "ToList()" in the GameManager script isnt working. Do you know why?
@taahaalbari Жыл бұрын
you are awesome! Thanks for the help & Great tutorial :D
@plutoniumbellamy19122 жыл бұрын
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!
@Joriku2 жыл бұрын
Thank you, took me hours to even get something to work. This got me able to shoot my current test enemy without issues
@GnuggetFPV2 жыл бұрын
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!
@PhantomInTheNight192 жыл бұрын
THIS is what i was looking for thanks
@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 Жыл бұрын
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 :)
@torontogamestudio29912 жыл бұрын
Can you make a tutorial on how the next scene will load after all enemies are killed?
@sharkao26862 жыл бұрын
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?)
@supernovascotian2 жыл бұрын
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.
@cryptolotl2 жыл бұрын
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?
@Moneybefehl2 жыл бұрын
@@cryptolotl im running into the same problem, ill update if i find a solution
@Moneybefehl2 жыл бұрын
@@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
@HunneProductions2 жыл бұрын
it works
@siickale11 ай бұрын
thanks for the tutorial
@n11ckz642 жыл бұрын
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!
@Stompin402 жыл бұрын
Holy sh*t this was sick to see!
@tuxedobird8379 Жыл бұрын
i followed it but now y bullet just goes through everything i dont know what i did
@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 Жыл бұрын
@@loozekh You have to add box collider (in the add component menu)
@LuanaSouza-fw1iz2 жыл бұрын
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
@BMoDev2 жыл бұрын
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
@fryptompt2 жыл бұрын
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 ?
@LesP562 жыл бұрын
How is this handled if the enemy is an instance of a prefab?
@BMoDev2 жыл бұрын
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();
@saishsawant74102 жыл бұрын
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 Жыл бұрын
Why the collisionEnter function is used in the projectile and not in the enemy?
@eileeng24922 жыл бұрын
Who should I test this on first?
@travnutztv2 жыл бұрын
Lost me at the game manager part. not sure if my "using"s are correct cause you never showed the top of the script.
@monkeypwners4 ай бұрын
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
@zendraw34682 жыл бұрын
why did you make the event in the enemies and not in the gamemanager? it shuld be the other way around
@iken_ar2 жыл бұрын
Thanks !
@fluffystuff2 жыл бұрын
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)
@nickcapria8172 жыл бұрын
.Count doesnt work for me any suggestions I get error CS0428
@MaestroMarc7 ай бұрын
It'd be neat if you made a 3D version of this tutorial!
@jooeyyjn6 күн бұрын
I used this for a 3d game. You do everything the same except wherever it says 2D, just don't put that.
@jrgvsgames56732 жыл бұрын
So i followed everything correctly but when i shoot my enemy it doesnt die? any help please?
@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_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 Жыл бұрын
what if i have couple enemy prefabs each named diffrently?
@cank42862 жыл бұрын
C# static events FTW! Unity Events and messaging suck :( . Only issue is += -= syntax is weird and causes noisy code.
@kacperkucharski4470Ай бұрын
my enemy just flew away, why ...
@noside68172 жыл бұрын
ty king
@Unknownuncovered-NIKI79 ай бұрын
broo You forgot the bullet part!!!!
@ryanem9692 жыл бұрын
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 Жыл бұрын
I have the same problem but i will just search other tutorial i guess
@ryanem969 Жыл бұрын
@@6fukraken Oh, I was a noob. I'm not pro now but ask me anything.
@Neon-no8kv2 жыл бұрын
could you use this script as a player script too BTW great tutorial!
@noahnyman44202 жыл бұрын
My enemies die in 1 shot :/ update: I die in 1 shot :/
@qdnr2 жыл бұрын
Спасибо
@eggseatpegs2 жыл бұрын
Yeet
@fongentripaloski2 жыл бұрын
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 ( )