Тёмный

How to make a DOOM CLONE in Unity || E1M2 Enemy Hit Detection 

SpawnCampGames
Подписаться 3,1 тыс.
Просмотров 16 тыс.
50% 1

In this video we update our player movement to include momentum then create the gun, along with enemies, enemy health, and a hit detection system.

Опубликовано:

 

12 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 92   
@de_soot
@de_soot 3 года назад
you're way too underrated man
@hawksjay1747
@hawksjay1747 2 года назад
This is a very interesting way of doing the gun script, first I’ve ever seen doing it this way. Well done 👍🏻 can’t wait to see more
@kingoflegends1029
@kingoflegends1029 2 года назад
My box collider script is not working for some reason, the EnemieInTrigger list is not updating Nevermind I fixed it turns out the gun object also needs a rigidbody to work properly
@qk4s
@qk4s 6 месяцев назад
You're a lifesaver. I've spent an hour trying to solve the same issue.
@waxpersons4695
@waxpersons4695 3 года назад
Love this tutorial so far!
@jorgesanchez4714
@jorgesanchez4714 9 месяцев назад
This script is amazing, may you live long and happy
@IAMMAT87
@IAMMAT87 Год назад
Thank you, i learn so much watching these videos.
@callimarie
@callimarie 2 года назад
i cant put the enemies in the enemymanager as you did at 16:35 the only thing avaliable when i press the circle thing next to it is the actual enemy manager script. nothing else
@redacted2713
@redacted2713 3 года назад
Time to get to work!
@TopGBari3077
@TopGBari3077 Год назад
@SpawnCampGames I can't seem to get my enemies to add and remove from the EnemyManager list
@petlahvickaanimations1
@petlahvickaanimations1 2 года назад
Thank you so much for these videos, Im new to coding and would have probably given up if it wasn't for you.
@TheMultiversalDip
@TheMultiversalDip 2 месяца назад
Did I perhaps make a mistake? I can't seem to shoot an enemy unless my I get up to even footing, if I jump above them or am on a ledge slightly below them, even if in the collider's range, they don't take damage. Did something change in these past 3 years or did I make a mistake somewhere?
@NestedBugs
@NestedBugs 3 года назад
Cool video!
@DavosTheDegen
@DavosTheDegen 11 месяцев назад
Enemy manager does not appear to work. Have ticket "IsTrigger" and rewatched video but can't figure it out
@TexasBakedBlackBeans
@TexasBakedBlackBeans 8 месяцев назад
There's an issue where for some reason no matter what I do, I can't seem to remove the enemy from the list once I kill it, even though I've skimmed over the video a few times, everything seems to be typed out correctly and I'm not getting any error in the console, but as soon as I shot an enemy, the enemy doesn't get removed from the list and the console says "The object of type 'Enemy' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object."
@TexasBakedBlackBeans
@TexasBakedBlackBeans 8 месяцев назад
It's not even an issue with destroying the enemy cause when i remove the "Destroy(gameObject);" part of the script, it still won't work
@maxisz6674
@maxisz6674 Год назад
Aside from what i commented in the other video, i was porting what i have to other computer with unity too, but when i try to shoot the enemy, after killing one it i can shoot well anymore and it says to not find the 'Enemy' because it was already destroyed and stops dealing damage
@aetomix_studios
@aetomix_studios 2 года назад
11:10 Saving my spot
@SpawnCampGames
@SpawnCampGames 2 года назад
I don't believe this error is related to the tutorial but I believe its an issue with the Camera. In the Inspector select your camera and look around and make sure nothing stands out. Check the clipping planes, Far clipping plane should be 1000 or something similar, the near clipping plane should be 0.3 or something similar. Make sure the field of view is something reasonable 40 - 100. The Scale of the Camera should always be (1,1,1). Try changing the Projection mode to Orthographic and then back to Perspective. Right click the Hierarchy and add a new camera. Use the new camera to double check your values.. Restart Unity and check again.
@slightlyangrybeluga
@slightlyangrybeluga 6 месяцев назад
I keep getting this compiler error error CS0246: The type or namespace name 'Enemy' could not be found (are you missing a using directive or an assembly reference?) how do you fix this?
@SpawnCampGames
@SpawnCampGames 6 месяцев назад
make sure that your enemy class is named `Enemy` and the file name is `Enemy.cs` If that class is in the project folder it should be able to reference it..
@slightlyangrybeluga
@slightlyangrybeluga 6 месяцев назад
Thank you for helping.@@SpawnCampGames
@TheDuccyGaming
@TheDuccyGaming 10 месяцев назад
my enemies won't die even though I shoot them. their health is set to the same in the video. big damage and small damage too
@slightlyangrybeluga
@slightlyangrybeluga 6 месяцев назад
I am having the same issue
@snbbit
@snbbit Год назад
[solved] update: redid all the scripts and got a bit further but now "Destroy(gameObject);" is getting an error "object reference not set to an instance of an object" update2: fixed it, for some weird reason each enemy had 2 enemy scripts, 1 of which had no enemy manager/particle effect (part3) applied. so bascially problem solved (old ver) im having an issue where it says "Assets\Scripts\EnemyManager.cs(7,17): error CS0246: The type or namespace name 'Enemy' could not be found (are you missing a using directive or an assembly reference?)" ill rewatch this vid in the morning to see if i missed anything but i thought id leave this comment before i do so
@Bazir459
@Bazir459 9 месяцев назад
help me pls Assets\Scripts\EnemyManager.cs(7,17): error CS0246: The type or namespace name 'Enemy' could not be found (are you missing a using directive or an assembly reference?)"
@joshmanhux6154
@joshmanhux6154 Год назад
Hey man love these videos your the first person to actually help me code a real game but, I don't get the Enemy Manager to go onto my gun Script in unity I checked all the code it is all the same except it says I have two errors, Assets\Scenes\Script Manager\Gun.cs(14,37):error CS1002:; expected The other one that I am getting is saying that OnGUIDepth changed: was 0 is 1. Event type was 0 nvm all that I found a way to fix it change "if(enemy)" to if(enemyManger) it worked for me
@aaroncabral7480
@aaroncabral7480 3 года назад
hay man very cool
@mainechang
@mainechang 2 года назад
a good tutorial, but i have a problem my enemieManager can't add and remove enemies, when i see to the enemies, the enemieManager don't add the enemies, i check the code and the code is the same as the video (with bit differences for the name of the classes), so... I need help :c
@kingoflegends1029
@kingoflegends1029 2 года назад
same problem
@joshmanhux6154
@joshmanhux6154 Год назад
same problem too
@joshmanhux6154
@joshmanhux6154 Год назад
I found a way to fix it change "if(enemy)" to if(enemyManger) it worked for me
@legendaryentertainment4421
@legendaryentertainment4421 Год назад
bro I got a question, I've already done every step on this tutorial, but when my Gun collides with an enemy the manager doesn´t work, and it doesn´t add the enemies to the list
@SpawnCampGames
@SpawnCampGames Год назад
I can assure you that the code works.. I have the project still on my hard drive and I go into it often. All I can say is its probably something very small that you have forgotten to do.. Or maybe some misspellings.. If you have no errors then nothing is broken just something keeping it from totally functioning as normal.. Make sure your enemies have the Enemy script.. thats how we detect them.. Make sure the gun box collider we create is marked as trigger. Make sure the Enemies have a Rigidbody component attached... (the trigger collider can't detect them without it) Make sure the Gun's layermask that we use has the layer that the enemies are assigned to selected.. (the raycast will only hit the things in this layer) .. thats about the basics.. make sure all those are fixed up and correct and it should work.. if not I can probably package this up into a UnityPackage so people having problems can just download it and import it
@Bazir459
@Bazir459 9 месяцев назад
give me sourse@@SpawnCampGames
@sputnick1
@sputnick1 3 года назад
poggers
@juanjosejaimescamargo2812
@juanjosejaimescamargo2812 2 года назад
Interesting way to approach the gun, what if the player has a pistol - would it still hit enemies above another or behind another even if i shoot only 1 bullet?
@SpawnCampGames
@SpawnCampGames 2 года назад
for a pistol instead of raycasting towards all the colliders in the loop i would probably do some additional logic and get the distance to the player for each collider and raycast towards the closest to the player or perhaps do a different system where u shoot multiple raycasts in a fan starting at the ground and going upwards and then damaging whichever enemy the first raycast hits..
@realkeysdev
@realkeysdev Год назад
it wont show Enemy Manager on the Enemy script in inspector (timestamp 12:22)
@u1krsh
@u1krsh 2 года назад
i'm getting an error the best overload for raycast does not have parameter nmaed origin nevermind solved it
@IceWolve67
@IceWolve67 2 года назад
But if let's say I change my key to not use WASD, then the "IF" for the momentum won't work, right ? If I decide to implement a menu to change keybindings (I still got to learn how to do that, hehe) is there a way to check for those, instead of hard writing the movement key ?
@Olphoracaca
@Olphoracaca Год назад
Instead I just did: if(Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0) so it will check for any kind of input that moves the axis.
@Kaleroni
@Kaleroni Год назад
these tutorials are great so far but after creating the enemies and enemy manager, the enemies my gun passes through doesn't add to the list in the EnemyManager. I re watched the video multiple times to check if my code is correct and I can't pinpoint what my issue is since I'm not getting any errors
@SpawnCampGames
@SpawnCampGames Год назад
Hmm, I'll pull up my Enemy Manager, Gun, and Enemy scripts tomorrow when I get off work and look and see if I can tell what would cause that issue... Have you tried adding in Debug.Logs to try to find the problem? if you don't get errors then you pretty much have to follow the process step by step to see where it fails.. this is an important part of every project, and knowing how to debug is something you'll have to do over and over.. just follow the sequence of steps the gun makes to get to where the enemy is damaged and then finally removed from enemy manager list... I would test with just 1 enemy.. You can debug.log when the gun fires debug.log and make sure that your raycast gets called correctly.. (should do that when you click mouse) just before the raycast then i would debug.log the raycast method.. by putting it just inside the raycast, if the raycast hits anything with a collider it should throw teh debug next you'd add one just below after you assign the enemy ( check if the enemy reference is ever assigned or if it returns null ) then finally if all that works you'd check inside the enemy script.. first make sure its getting damaged, then if its health is getting less than zero.. then finally debug.log where it gets removed from the enemy manager.. (also make sure the enemy manager is clicked and that you are watching it in the inspector as you test.. you should be able to see it get filled when you start the game.. then see it get removed after it gets its health drained..)
@Kaleroni
@Kaleroni Год назад
@@SpawnCampGames So my issue was one tiny thing that i kept missing was setting the box collider for the gun to "Is Trigger" lol
@SpawnCampGames
@SpawnCampGames Год назад
@@Kaleroni Nice! Always good to see people solving their bugs :D
@Kaleroni
@Kaleroni Год назад
​@@SpawnCampGames thank you. i love these tutorials though, they get straight to the point and they teach the coding logic well. it keeps somebody like me who gets easily distracted, focused on the video
@IceWolve67
@IceWolve67 2 года назад
Hi, how would it work if I wanted to create different ennemies or weapon type with each their amount of HP or different rage/rate of fire ? Can I just, for ennemy HP, copy and paste an enemy, but just changing the health variable (after setting it to public) ?
@SpawnCampGames
@SpawnCampGames 2 года назад
well for enemies u can have their logic in seperate scripts.. rangedenemy, meleeenemy, etc... the enemy health script can be universal. just put it on every enemy and assign the starting health or whatever.... same with the gun.. u can copy and paste it as a new script.. pistol.cs, shotgun.cs and change the range and damage amounts... then u could have different child objects like pistol, shotgun, etc.. and just enable the ones u not carrying and so on... there is cleaner ways of doing this but since this is a beginner type series we're gonna do what i mentioned first... reusing as many of the scripts as we can... and only making new ones if the functionallity is majorly different
@AidinZolghadr
@AidinZolghadr 2 года назад
How did you add the gun itself and made it bob/sway as you move? (Also shoot animations and gun model)
@SpawnCampGames
@SpawnCampGames 2 года назад
It bobs because of the camera movement.. I threw the gun in quickly but will have a full tutorial on how to add either a 3d model or a sprite for the gun in an upcoming tutorial.
@SpawnCampGames
@SpawnCampGames 2 года назад
Oh yea for the horizontal sway I just created an animator on the gun image and it just loops whenever ur walking.. else it goes back to idle.. which is just centered..
@luckyducky7819
@luckyducky7819 2 года назад
How would I do a version of this, but with free mouse looking? I want to make a blend of a retro shooter and modern shooters.
@SpawnCampGames
@SpawnCampGames 2 года назад
paste.ofcode.org/39t9RbKCMvX2phPfTHeSNDW heres my custom mouse script... Your move script moves the player left right, forward and backwards this camera would be a child of that naturally, in the camera script u assign the player gameobject ( the object u want to rotate left and right) the camera script rotates the player left and right: player.transform.localRotation = Quaternion.AngleAxis(currentLookingPos.x, player.transform.up); and it rotates itself up and down, on the line above that: transform.localRotation = Quaternion.AngleAxis(-currentLookingPos.y, Vector3.right); now, take note that the rest of the tutorials are setup for not being able to look up and down.. so there will be some things u need to change... so most likely the box collider we use for the gun wont work as well, so raycasting would probably be the better option if u have a free looking first person camera... anyway, hope that gets u started, GL and happy developing! 🙂
@luckyducky7819
@luckyducky7819 2 года назад
@@SpawnCampGames Ok, thanks for the code. I noticed there's a variable called "adjustedSesitivity" that I don't have. Will this be added later on in the tutorial? I replaced it with "smoothing" and everything works, but I wanted to ask to be sure. I'll continue with the rest of the tutorial, and comment again if the free looking code is giving me any more trouble. Thanks for making these vids by the way!
@SpawnCampGames
@SpawnCampGames 2 года назад
@@luckyducky7819 ohh.. not sure about the adjusted sensitivity.. i pulled this code off a seperate character controller that I use... if its not used in the update or anything just comment it out for now //float adjustedSensitivity; sorry, didnt catch that OH!, it *may* be the smoothing i called something else in the other character controller.. if it works for now i'd just go with it 👍
@nat22157
@nat22157 2 года назад
is there a way to only make it attack the nearest enemy?
@SpawnCampGames
@SpawnCampGames 2 года назад
As, it is now it'll only attack the first enemy if one is standing in front of the other.. now, if they are a little staggered and theres a straight shot to both of them then yes, the raycast might get to it and damage it too.. if dont want that to happen you could always make the gun's box collider a little more narrow so it only detects enemies straight in front, but then you lose some of that auto-aim feel..
@Bazir459
@Bazir459 9 месяцев назад
PLS SCRIPT ON: GUN, enemy manager and enemy!!!! I'M NOT GETTING ANYWHERE😭😭😭
@itztrayday2216
@itztrayday2216 3 года назад
The box collider isn't detecting anything
@SpawnCampGames
@SpawnCampGames 3 года назад
On the gun script make sure your raycast layermask and your enemy layermask both contain enemy.. Make sure the enemy gameobject is set as Enemy in the layer dropdown.. lastly make sure it has a collider that's not set as trigger, a rigidbody, and the enemy script attached..
@juliaribeirobitencourt7919
@juliaribeirobitencourt7919 23 дня назад
podia ter aumentado a porra da letra né mano, tá achando q eu tenho visão do mega olhos?!
@SpawnCampGames
@SpawnCampGames 22 дня назад
Its the same size font as it'd be *inside* the game-engine..
@mariobloopy1063
@mariobloopy1063 3 года назад
momentum doesn't work for me. I have to spam W to move.
@SpawnCampGames
@SpawnCampGames 3 года назад
Make sure you're using GetKey and not GetKeyDown
@mariobloopy1063
@mariobloopy1063 3 года назад
@@SpawnCampGames Thank You!
@bean4997
@bean4997 3 года назад
i'm 95% sure i did everything correctly, yet the head bob animation plays even when i'm not walking
@bean4997
@bean4997 3 года назад
nevermind, it was because i forgot to set the second "isWalking" to false.
@ther7513
@ther7513 3 года назад
14:14 i got an error saying "Invalid token '{' in class, struct, or interface member declaration" pls help
@SpawnCampGames
@SpawnCampGames 3 года назад
that's probably saying u have an extra } somewhere and it wants you to add a { to make it valid.. just look over the code and you'll probably find that you have an extra bracket somewhere in the code.
@SpawnCampGames
@SpawnCampGames 3 года назад
which script is this on? ill post up a link to the exact code
@ther7513
@ther7513 3 года назад
@@SpawnCampGames gun.cs
@SpawnCampGames
@SpawnCampGames 3 года назад
@@ther7513 gist.github.com/SpawnCampGames/53d68848f0d3321e5af3b0e53dcefec5 here ya go mate.. something u can check against to see if u can find an extra or missing bracket, semi-colon, etc
@ther7513
@ther7513 3 года назад
@@SpawnCampGames thanks
@SuperGamePlayOfficial
@SuperGamePlayOfficial 2 года назад
I got stuck with the enemy manager the enemys dont show up in the list and i cant kill them the gun collider adjust correctly no errors, enemy kinematic enemy manager on the enemys
@SuperGamePlayOfficial
@SuperGamePlayOfficial 2 года назад
also E1M2 is missing from GitHub
@SpawnCampGames
@SpawnCampGames 2 года назад
Make sure ur layers are set up correctly..
@SpawnCampGames
@SpawnCampGames 2 года назад
@@SuperGamePlayOfficial ill check it out
@SuperGamePlayOfficial
@SuperGamePlayOfficial 2 года назад
@@SpawnCampGames layers? U didnt show that in the video
@SuperGamePlayOfficial
@SuperGamePlayOfficial 2 года назад
Just make a enemy and a gun layer
@user-zk5qo9wr4t
@user-zk5qo9wr4t 2 года назад
And which key to shoot?
@SpawnCampGames
@SpawnCampGames 2 года назад
any key u wanna use :) I use MouseButton 0 which is the left mouse button but u can use any button or key u chose.. if (Input.GetMouseButtonDown(0)) Debug.Log("Pressed primary button."); if (Input.GetMouseButtonDown(1)) Debug.Log("Pressed secondary button."); if (Input.GetMouseButtonDown(2)) Debug.Log("Pressed middle click.");
@user-zk5qo9wr4t
@user-zk5qo9wr4t 2 года назад
@@SpawnCampGames Thank you!
@MasterPlunger
@MasterPlunger 3 года назад
got an error saying "argument 3 may not be passed with the 'out' keyword; line 46" i am confused
@MasterPlunger
@MasterPlunger 3 года назад
nevermind im dumb and am trying to do it instead with a quaternion camera instead of the regular x axis only camera and the box collider wasnt detecting anything because of the range
@u1krsh
@u1krsh 2 года назад
Doy you have a discord i;m having some issues
Далее
OG Buda, Слава КПСС - LAZER SLAVA
01:58
Просмотров 59 тыс.
ДОМИК ДЛЯ БЕРЕМЕННОЙ БЕЛКИ#cat
00:45
I made DOOM in Unity!
14:07
Просмотров 91 тыс.
FIRST PERSON MOVEMENT in Unity - FPS Controller
23:53
How to Make Grappling Gun in Unity (Tutorial)
10:23
Просмотров 861 тыс.
Weapon Switching - Unity Tutorial
9:59
Просмотров 427 тыс.
FULL 3D ENEMY AI in 6 MINUTES! || Unity Tutorial
5:52
Просмотров 630 тыс.