How to make ALL kinds of GUNS with just ONE script! (Unity3d tutorial)

  Рет қаралды 314,055

Dave / GameDevelopment

Dave / GameDevelopment

Күн бұрын

Пікірлер: 1 500
@davegamedevelopment
@davegamedevelopment Жыл бұрын
If you need help with any of the code shown, just visit the "coding-help" channel on my discord server :D Also you can find many more movement tutorials on my channel in the "Tutorials!" playlist - I really hope they help you on your further GameDev journey! And in case you're interested in getting access to my full RANGED COMBAT LAB, with which you can create pretty much any ranged ability/weapon you can think of, check out the trailer: 🏹 RcLab Trailer: kzbin.info/www/bejne/oGO8oZ-foa2deaM Thanks so much for watching, hope this tutorial has helped you!
@RainCoatCult
@RainCoatCult Жыл бұрын
Any ideas on how to use this with the new input system? I'm working through it now with plans to try to integrate it with the new system but any guidance would be greatly appreciated.
@malachi6798
@malachi6798 Жыл бұрын
what is the game object that is called gun and Attack point also what is the oint a transform i just need to now these things and thenimm all good
@Siuuu974
@Siuuu974 8 ай бұрын
kannst du auch deutsch?
@Andy6h1l
@Andy6h1l 4 жыл бұрын
I found Brakeys' second channel! Woohoo!
@mahmoud-quran
@mahmoud-quran 4 жыл бұрын
Haha he sounds so much like him
@Werner-sv2le
@Werner-sv2le 3 жыл бұрын
I was very hopeful for a second until I found out if wasn't him
@ruleamormedia3747
@ruleamormedia3747 3 жыл бұрын
Thought the voice was familiar
@diliupg
@diliupg 3 жыл бұрын
This is him, spread the word.
@infinixs4600
@infinixs4600 2 жыл бұрын
Absolutely me too
@haydenmcturk2329
@haydenmcturk2329 2 жыл бұрын
I feel like this needs to be said, ShootAI and CamShake are different scripts if you get errors about them just delete the lines it isn't going to affect the code. For an explaination on what they do, ShootAI is simply your enemy ai script and all the line does is make it so when you hit that ai they take damage equal to your damage parameter if you don't have ai yet this code returns an recognize error. CamShake is a script that shakes the camera when you shoot this is the same thing if you don't have a camshake script it will return an error. If your Muzzle flash isn't working make sure its set to play on awake, if its not it will wait for a trigger to play it, we don't use a trigger to play the effect. If your bullet holes aren't rotating right set it to this Instantiate(BulletHoleGraphic, RayHit.point, Quaternion.LookRotation(RayHit.normal)); just make sure that your variables are named correctly as I prefer a different naming convention all this does is makes it so we us the the bullet holes normal rotation as opposed to setting on manually. Instantiate(BulletHoleGraphic, RayHit.point, Quaternion.LookRotation(RayHit.normal)); Your bullet hole Your ray Your ray variable variable variable
@Aaron-vn5fd
@Aaron-vn5fd 2 жыл бұрын
bless you! I was looking through the comments for these very words
@RiceR6art-l9k
@RiceR6art-l9k Жыл бұрын
how do i get the muzzle flash to be set to play on awake?
@RiceR6art-l9k
@RiceR6art-l9k Жыл бұрын
nevermind i found out how
@RiceR6art-l9k
@RiceR6art-l9k Жыл бұрын
bullet holes aren't appearing though?
@raunaksharma8638
@raunaksharma8638 11 ай бұрын
Thnx a lot brother your comment was a lot helpful .
@dellusenew123
@dellusenew123 6 ай бұрын
If you have problems like: 1. Bullet holes spawns at 0 0 0 coordinates. 2. Bullet holes are incorrect shape or rotation. 3. Muzzle effect doesn't disapear or you can't see it. 4. You have an errors. 5. Other stuff like this. Then just replace this part of code: ============================================================================================================ if (Physics.Raycast(fpsCam.transform.position, direction, out rayHit, range, whatIsEnemy)) { Debug.Log(rayHit.collider.name); if (rayHit.collider.CompareTag("Enemy")) rayHit.collider.GetComponent().TakeDamage(damage); } //Graphics Instantiate(bulletHoleGraphic, rayHit.point, Quaternion.Euler(0, 180, 0)); Instantiate(muzzleFlash, attackPoint.position, Quaternion.identity); ============================================================================================================ To this: ============================================================================================================ GameObject flash = Instantiate(muzzleFlash, attackPoint.position, Quaternion.identity, attackPoint); Destroy(flash, 0.1f); if (Physics.Raycast(fpsCam.transform.position, direction, out rayHit, range)) { if (((1
@krzaczastyyt6547
@krzaczastyyt6547 5 ай бұрын
I Love you
@--l6070
@--l6070 Ай бұрын
Also it is better to create an empty child of the gun and put it to the end of the barrel.
@koolgoose
@koolgoose 4 жыл бұрын
Amazing tutorial! Kept it interesting throughout the entire video, great clarity and quality, and one of the only tutorial videos that I don’t have to put to 1.5x speed. Good job!
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Thanks a lot man! :D
@smitasushilbhegde3655
@smitasushilbhegde3655 2 жыл бұрын
But for me its still gonna go to 2x
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Was the explanation a bit too fast, or could you keep up easily? :D And do you want to see more tutorials, if yes, which ones?
@ahmadgamal9587
@ahmadgamal9587 4 жыл бұрын
i need a weapon bob for my fps can make a video for it
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
@@ahmadgamal9587 Thanks for the suggestion! :D But not quite sure yet if I'll do a tutorial about it.
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
@Mostafa_XS1 Strange it should work, anyway, you can download it here: filebin.net/6rmyd4e7rppup71d And yes you can add aiming, just search on youtube for "unity gun scoping" :D
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Zephaniah Archer The easiest way would be to just make different gun objects with different 3D models and scripts (all inside of the players camera). Afterwards you just need to make ui buttons before the match starts, for example the shotgun button would first deactivate all guns and then activate the shotgun. :D
@taylormarinescu805
@taylormarinescu805 4 жыл бұрын
I could keep up
@sama-vh8ge
@sama-vh8ge 2 жыл бұрын
This channel has single handedly helped me relearn c# and unity. Fantastic resource, straight to the point.
@davegamedevelopment
@davegamedevelopment 2 жыл бұрын
That's awesome to hear! Thanks a lot!
@JVC0B
@JVC0B 4 жыл бұрын
Very clean explanation! You had a lot of information packed into a short amount of time, which was great! Keep it up :)
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Chillehh Thank you! :D
@davegamedevelopment
@davegamedevelopment Жыл бұрын
@OPchees Thanks man, appreciate it!!
@MkbballAnimations
@MkbballAnimations Жыл бұрын
@@davegamedevelopment hi
@obnoxiousnoise7411
@obnoxiousnoise7411 2 жыл бұрын
I haven't started the code yet but I already know that this tutorial will be EXACTLY what I need for the game I wanna make
@SleepDreamDev
@SleepDreamDev 3 ай бұрын
hows it going with the code bro
@obnoxiousnoise7411
@obnoxiousnoise7411 3 ай бұрын
@@SleepDreamDev It was actually going really well but I've had to take an extended hiatus from coding cuz of my job
@SleepDreamDev
@SleepDreamDev 3 ай бұрын
@@obnoxiousnoise7411 what where you working on?
@obnoxiousnoise7411
@obnoxiousnoise7411 3 ай бұрын
@@SleepDreamDev Once it was finished it would've been an fps where you can hijack robots and use their weapons/skills to destroy other robots. There wasn't gonna be any healing system so the only way to survive would've been to constantly jump from bot to bot. Was a simple idea but now it's collecting dust in the back of my folder
@trader9926
@trader9926 2 жыл бұрын
We all know you are just brackeys doing his Elizabeth holmes voice impression. Just kidding you’re awesome great videos man very educational!
@davegamedevelopment
@davegamedevelopment 2 жыл бұрын
Thanks a lot!
@1nput_0
@1nput_0 2 жыл бұрын
amazing and straight forward!! definitely will recommend this to anyone who needs a simple and useful gun system. good work :D
@davegamedevelopment
@davegamedevelopment 2 жыл бұрын
Thanks a lot!
@PostcardFromADream
@PostcardFromADream 4 жыл бұрын
Damn was this frustrating, but after finally getting it to work I'm loving it. Can't wait to build upon this foundation. Thank you so much for helping this complete beginner!
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
I feel you, coding is so strange sometimes^^ But glad it helped you! :D
@Lazyy-Gamer
@Lazyy-Gamer Жыл бұрын
@@davegamedevelopment bro but i getting and error of "ShootingAi" could not be found
@1qqa1sddlpfds
@1qqa1sddlpfds Жыл бұрын
me to but why ?@@Lazyy-Gamer
@zy2684
@zy2684 Жыл бұрын
@@1qqa1sddlpfds its because your object which you attached the script to does not have a component (components are things you can attach to your gameobjects) called ShootingAi
@1qqa1sddlpfds
@1qqa1sddlpfds Жыл бұрын
that's was helpful thanks@@zy2684
@divyanshpathak2506
@divyanshpathak2506 4 жыл бұрын
Man You are EPIC But please upload more tutorial(Noobs really need it-just like me)
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Thanks a lot! :D And yes I'll definitely do more, today comes one similar to this, but about shooting with real bullets instead of raycasts :D
@acemoistman
@acemoistman 4 жыл бұрын
​@@davegamedevelopment Totally agree keep em comin bro you make it super easy to understand. Somehow faster than Brackeys
@M1nozVL
@M1nozVL 4 жыл бұрын
yeees
@ipga13
@ipga13 3 жыл бұрын
i only get the type or namespace ShootingAi could not be found(are you missing a using directive or an assembly reference?)
@Meekailonyt
@Meekailonyt 3 жыл бұрын
@@ipga13 you have to make a script called shootingai and have a damage function in it
@DucatChannel
@DucatChannel 3 жыл бұрын
4:00 You DO realize that Vector3(x, y, 0) - makes you able to spread only when you look along with the Z axis, and if you turn to 90 degrees - it will spread only verticaly?
@sajflatter
@sajflatter 3 жыл бұрын
@BurliestStorm94 replace it with Vector3 (0,x,y) and it will be tip-top
@FoxyGame2006
@FoxyGame2006 2 жыл бұрын
@@sajflatter No, to solve this make float z like the x and y with the random method, and place these like (x, y, z)
@marcopadeiro3021
@marcopadeiro3021 3 жыл бұрын
Can you help me? I'm having a problem where the bullets hole only stick to one rotation and dont rotate, so for example if im inside of a cube only one side has the right bullet hole rotation and the rest is rotated
@ItzBetrayed
@ItzBetrayed 3 жыл бұрын
Thanks for putting the code in the description otherise i would have been siting here for 3 hours writing all the code amazing tutorials i wish you success!
@wtmftproductions
@wtmftproductions 3 жыл бұрын
Your spread is going to result in a box rather than a cone. Create a vector2 and normalize it to make it a conical spread.
@daoollaa
@daoollaa 2 жыл бұрын
can you please tell me more about it? Or better yet, an example
@wtmftproductions
@wtmftproductions 2 жыл бұрын
@@daoollaa sure! If you have a random X between -1 and 1, and same for Y, there's always a good chance that both the X and Y will get numbers close to the extremes, such as (1, 1) which is farther away from the center than (0, 1) for example. If you want a random spread in the shape of a circle/cone/sphere you want every extreme to be the same distance from the center, so you just have to Normalize the result. So a random X,Y of (1, 1) will end up being something like (.7, .7) which is still 1 away from the center just like (0, 1) is 1 away from the center.
@wtmftproductions
@wtmftproductions 2 жыл бұрын
In Unity, any Vector variable has a member function for Normalize
@wtmftproductions
@wtmftproductions 2 жыл бұрын
I forgot to mention that Normalize will also make any Vector that is smaller than a magnitude of 1 into 1. So for a gun shooting where you want it to spread, you only want to Normalize vectors with a magnitude greater than 1.
@1worldgaming518
@1worldgaming518 Жыл бұрын
for some reason when i shoot the bullet hole appears at 0,0,0 instead of where the raycast go's
@ThisAccountIsDead333
@ThisAccountIsDead333 8 ай бұрын
Did you ever find a solution to this 😩😩😩
@terrydafunny7077
@terrydafunny7077 7 ай бұрын
@@ThisAccountIsDead333 have you found one?
@Magaelcrack
@Magaelcrack 4 жыл бұрын
really good, I also like making game so this is really helpful! I personally like more scriptableobjects but each one has its own way!
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Thanks a lot! :D
@gaminganimator-qp2ir
@gaminganimator-qp2ir 4 жыл бұрын
@@davegamedevelopment where to put the script
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
@@gaminganimator-qp2ir On your gun :D
@gaminganimator-qp2ir
@gaminganimator-qp2ir 4 жыл бұрын
making games is more fun then playing games
@blokkiesotto5854
@blokkiesotto5854 2 жыл бұрын
@@gaminganimator-qp2ir trueeeeeeeeeee
@TheThirty
@TheThirty Ай бұрын
helpful tip: if you find out that your bullet spread only works properly in one or more axes, but appears to be a straight line in another, its because you have to add a "z" variable to the script. it should look like this: float x = Random.Range(-bulletSpread, bulletSpread); float y = Random.Range(-bulletSpread, bulletSpread); float z = Random.Range(-bulletSpread, bulletSpread); Vector3 direction = playerCam.transform.forward + new Vector3(x, y, z);
@Adrakxys
@Adrakxys 2 жыл бұрын
For some reason muzzle flash and bullet holes are both invisible. The muzzle flash is appearing where it should in the scene but in game I cant see it, the bullet holes go to 0,0,0. Any fix for this? edit - to fix no muzzle flash issue check play on awake in the muzzle flash prefab
@sx6002
@sx6002 Жыл бұрын
YOU LEGENDDDD THANKS SO MUCHHHH
@goofyahhmoron1141
@goofyahhmoron1141 Жыл бұрын
did you fix the bullets going to 0,0,0??
@renky_ren
@renky_ren Жыл бұрын
OMFG thank you, finally i fix the muzzle flash issue
@terrydafunny7077
@terrydafunny7077 7 ай бұрын
@@goofyahhmoron1141 have you managed to fix btw
@lukekennedy7340
@lukekennedy7340 7 ай бұрын
​@@terrydafunny7077 i managed to fix it by spawning a wall and tag it as enemy,
@user-05-o8l
@user-05-o8l Жыл бұрын
Jo, I need help! Assets\Scripts\ShotAnimation.cs(64,86): error CS1503: Argument 3: cannot convert from 'out UnityEngine.Vector3' to 'out UnityEngine.RaycastHit' Assets\Scripts\ShotAnimation.cs(64,97): error CS1503: Argument 4: cannot convert from 'UnityEngine.RaycastHit' to 'float' Assets\Scripts\ShotAnimation.cs(69,18): error CS0122: 'CameraShake.Shake(float, float)' is inaccessible due to its protection level
@Nico-un1ey
@Nico-un1ey 4 жыл бұрын
Hey there, while writing the code i had an error with "ShootingAi", it says that i'm missing a director or a assembly reference, any recomendations?
@GianniPapetti
@GianniPapetti 4 жыл бұрын
You have to create that script first
@GianniPapetti
@GianniPapetti 4 жыл бұрын
@@kansaslml7796 i don't he made a video of that, but all i can presume is that he made another script called ShootinAi
@OrangutanMonky
@OrangutanMonky 4 жыл бұрын
@@GianniPapetti what to write in that script
@GianniPapetti
@GianniPapetti 4 жыл бұрын
@@OrangutanMonky that's a script with a TakeDamage function in it, maybe it's a script to manage the enemy with his health and shooting system
@couchwow
@couchwow 4 жыл бұрын
if you dont have one, delete it, the code is useless and unity is clueless on how to use it.
@hinthujanthiagarajah1975
@hinthujanthiagarajah1975 4 жыл бұрын
Heyo! I just found a bug while playing around with your script. I made a burst gun and clicked really fast, it seems like the readyToShoot is getting overridden being to set true, while spamming the mouse button. It seems like it has something to do with the invoke method of ResetShot being called multiple times resulting in readyToShoot being set to true. So your burst gun acts more like a AR. You can really see this effect if you have allow button hold set to true. Edit: I fixed the problem, just before you invoke the ResetShot have a if statement checking for if u already are invoking the resetshot method. if(!IsInvoking("ResetShot") && !readyToShoot) !readyToShoot is just to be extra sure { Invoke("ResetShot, timeBetweenShooting); }
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Thanks for reporting the bug! :D Here's how to fix : 1. make a new bool "allowInvoke" and set it to true at the start of the game 2. Go to the Shoot() function, replace the current ResetShot Invoke with this : if (allowInvoke) { Invoke("ShotReset", timeBetweenShooting); allowInvoke = false; } 3. In ResetShot() set allowInvoke to true again Hope this helps! :D
@hinthujanthiagarajah1975
@hinthujanthiagarajah1975 4 жыл бұрын
@@davegamedevelopment Yeah :) i did it in a different way, if you click on show more on my orginal comment. Both ways are good! :) Have a great day :)
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
@@hinthujanthiagarajah1975 Ah your code is a lot cleaner! :D I forgot about the "isInvoking" bool... Thanks for sharing!
@MkbballAnimations
@MkbballAnimations Жыл бұрын
@@hinthujanthiagarajah1975 hi
@konamisenpai8018
@konamisenpai8018 Жыл бұрын
Hello can you help me. I don't know which line of the code I will paste the fix
@Nviius56
@Nviius56 2 жыл бұрын
For people that have the bullet holes only show up in one axis direction you can comment out the current "Instantiate(bulletHoleGraphic, rayHit.point, Quaternion.Euler(0, 180, 0));" and replace it with Instantiate(bulletHoleGraphic, rayHit.point , Quaternion.FromToRotation(Vector3.forward, rayHit.normal));
@blitzzyboi3012
@blitzzyboi3012 2 жыл бұрын
Thank you!!!
@malachi6798
@malachi6798 Жыл бұрын
my gun don't shoot
@uphjo6969
@uphjo6969 Жыл бұрын
it clips with stuff :(
@logan_Makegames
@logan_Makegames Жыл бұрын
dont work
@TETE
@TETE Жыл бұрын
shemogevle
@IrfuTuber
@IrfuTuber 2 жыл бұрын
"Yes" looks pretty Fun to Shoot With!
@miragenegs
@miragenegs 2 жыл бұрын
Great tutorial! one question on line 25 there is an error that states there is no such thing as camshake what do i do
@Fillyshejay
@Fillyshejay 2 жыл бұрын
im having the same problem man
@vbai5664
@vbai5664 2 жыл бұрын
Is says CamShake sould nt be found help pls!!!
@TheJungaBoon
@TheJungaBoon 4 жыл бұрын
I have a question about the Raycast spread. When I try it, it works fine if I'm facing the World Forward direction, but it doesn't seem to calculate the Player's forward position. If I turn to the sides, it still calculates the world forward. Any help? Thanks.
@aleksp8768
@aleksp8768 3 жыл бұрын
Same
@Walter_Hartwell_White356
@Walter_Hartwell_White356 2 жыл бұрын
i have been reading the comments and you really help the people! so here is your like and my sub, great video
@davegamedevelopment
@davegamedevelopment 2 жыл бұрын
Thank a lot!
@samisalama3033
@samisalama3033 2 жыл бұрын
if you are helping can you help me and tell me how to get CamShake?
@MKI-eq8ok
@MKI-eq8ok 2 жыл бұрын
@@samisalama3033 there is a video in the desc showing how to do it
@selahattinturan1419
@selahattinturan1419 3 жыл бұрын
hi I have a question ? I have a error , can you take a look (sorry for my english) Assets\GunSystem.cs(25,12): error CS0246: The type or namespace name 'CamShake' could not be found (are you missing a using directive or an assembly reference?)
@Boxply
@Boxply 3 жыл бұрын
The error indicates that camera shake was not referenced, meaning you haven't had a camera shake effect which wasn't really needed. You could cut out the code which has the camera shake
@AZASeraph
@AZASeraph 3 жыл бұрын
I got the same error
@Walter_Hartwell_White356
@Walter_Hartwell_White356 2 жыл бұрын
lol, so the bullethole impact is pink and spawns at 0,0,0 no matter what and the muzzleeffect doesnt delete XD sorry for bad english im still learning
@davegamedevelopment
@davegamedevelopment 2 жыл бұрын
1. It's pink because unity can't load the right materials (you probable didn't import it correctly) 2. You need to spawn it at hit.point 3. Create a new script on the muzzleEffect: void Start{ Invoke(nameof(DestroyEffect), 1f); } void DestroyEffect(){ Destroy(gameObject); } This will destroy the muzzle effect after 1 second
@Walter_Hartwell_White356
@Walter_Hartwell_White356 2 жыл бұрын
@@davegamedevelopment thx dude! i solved it :D you are awesome
@withiethecryptid9259
@withiethecryptid9259 Жыл бұрын
Great tutorial! Are there any tutorial videos on how to make the gun ammo limited so you have to pick up extra ammo from the environment around you?
@miguelclemente4979
@miguelclemente4979 2 жыл бұрын
The bullet hole graphic doesn't appear when I hit anything BUT the enemy. it only appears at a certain point(at 0,0,0 i presume) and I don't know how to fix this. pls help
@mixedtrigenito
@mixedtrigenito 2 жыл бұрын
replace it with Vector3 (0,x,y) and it will be tip-top
@connorrice7610
@connorrice7610 2 жыл бұрын
@@mixedtrigenito where do I replace 0,0,0 with vector3?
@LandonIsbell29
@LandonIsbell29 9 ай бұрын
I know this was a long time ago, but if you're range for the gun was set to 0 like mine, the bullet hole would go to 0,0,0 because it had nowhere to go. If you set your range to something around 100, then it would work. That fixed it for me.
@ThisAccountIsDead333
@ThisAccountIsDead333 8 ай бұрын
@@LandonIsbell29that did not fix it for me :( mine was already 100
@LandonIsbell29
@LandonIsbell29 8 ай бұрын
@@ThisAccountIsDead333 Oh. I don't know why it wouldn't be working other than that. My Unity project crashed and I fixed everything except for the shooting bullets. When I left click the gun doesn't shoot and doesn't do any damage either. I didn't have a backup file and now I know: always have a backup file for your Unity project.
@rincon175
@rincon175 3 жыл бұрын
i have a problem when i shoot the muzzle flash doesn't stay at the attack point when I'm moving around
@Galepic
@Galepic 3 жыл бұрын
did u solve it? im having the same issue
@liptojaj
@liptojaj 3 жыл бұрын
I can't see my muzzle flash and the game object doesn't despawn, I felt like I did something wrong with the tutorial but after copying the whole code it still persists, any idea why this is?
@mincha9999
@mincha9999 3 жыл бұрын
can i get the code man?
@pelztierssohn8198
@pelztierssohn8198 2 жыл бұрын
When I use the code shown, I get the following error: "The type or namespace name 'ShootingAi' could not be found (are you missing a using directive or an assembly reference?)" What have I been missing?
@pizzaslijm2114
@pizzaslijm2114 2 жыл бұрын
Just delete the line, it is only if you have a script for shooting AI to let them take damage!
@Lazyy-Gamer
@Lazyy-Gamer Жыл бұрын
guys thanks alot to both of you cause i got headache by trying to fix the error you uys helped me a lot thanks Jai shree ram
@TheRealSnowyGuy
@TheRealSnowyGuy 3 жыл бұрын
OMG THANKS, I tried making my own script and didn't get it a bit close and thanks to you I can!
@fatdumduck
@fatdumduck 3 жыл бұрын
Dave : says 15 times in th video the word "stuff" to discribe things Me : Understand every single "stuff" he is talking about cOmUniCAtIon
@SensibleStuff
@SensibleStuff 3 жыл бұрын
Hello... ~ from Sensible *Stuff*
@accountdisbanded
@accountdisbanded 3 жыл бұрын
@@SensibleStuff goodbye from qapch
@yogaagustina6501
@yogaagustina6501 4 жыл бұрын
really good tutorial mate. simple and clear explanation. keep up the good work. can't wait for your next tutorial
@SirJustinn
@SirJustinn 4 жыл бұрын
Can you show me the script
@Flyomega
@Flyomega 3 жыл бұрын
Mec c'est incroyable ce carry j'espère que tu as ou que tu vas avoir une vie incroyable. Juste merci ;)
@salesbanglore1926
@salesbanglore1926 3 жыл бұрын
Nani
@jellybeans7729
@jellybeans7729 2 жыл бұрын
I have an issue where the bullet holes are in one place and will only show up at certain angles and after the first shot will not appear anymore
@ghlow6346
@ghlow6346 2 жыл бұрын
For anyone who's bullet holes are not spawning, remove all instances of whatIsEnemy from GunSystem.cs and it should work fine.
@Jay___ink
@Jay___ink 2 жыл бұрын
This is amazing most precise, straight forward script i have seen for setting up weapons. I have two questions firstly can the same script be assigned to various different weapons and tweaked to match it. The second more complex question is can this be adapted and used with VR if so could you do a video on that if its not too much trouble. But thanks again for soo much information in such a short amount of time!
@griffinbrooks6748
@griffinbrooks6748 4 жыл бұрын
how do you make the bullet hole graphic where you hit?
@Airsickword
@Airsickword 4 жыл бұрын
was about to comment that you sound like Brackeys, then it clicked
@dragonman7806
@dragonman7806 3 жыл бұрын
same bruh
@destroyergames1965
@destroyergames1965 Жыл бұрын
The player cam script won’t be assigned to the cam shake variable the text won’t be assigned either and the particle pack won’t import what do I do
@ethancossett7318
@ethancossett7318 3 жыл бұрын
This works really well, although for some reason my spread X/Y variables seem to be operating in some kind of world space wherein they only "spread" properly on certain camera rotations, otherwise the raycasts all stack up in the same place. Has anyone else experienced this?
@qShaun
@qShaun Жыл бұрын
are you still having this issue?
@konamisenpai8018
@konamisenpai8018 Жыл бұрын
@@qShaun me please help
@IAShepherd.p
@IAShepherd.p 11 ай бұрын
@@konamisenpai8018 If this is still relevant, the problem is that when you type Vector3 direction = fpsCam.transform.forward + new Vector3(x, y, 0); the x and y values are world coordinates that are not relative to where you are looking. So, when you shoot an object facing z directly, you'll get a nice square spread, but any angle slightly off of the z axis will result in a distorted square, as if you viewed the original 2D square from the side. Then when you look perpendicularly to z, the square will be distorted as if you viewed a plane from the side. I just hit this problem and I'll follow up if I fix it. [Edit] 3 solutions: 1: Use trig to get the x and y values relative to the camera. 2: Use a sort of cone rather than a box. There's a comment near the top that explains that. 3: Chicken out and add a z value so there is always some dimension to the spread. (I did this one)
@MrMattyMoses
@MrMattyMoses Жыл бұрын
Super new to Unity. Love the channel!
@zabby13
@zabby13 4 жыл бұрын
if i jump to a wall and click A/D i stick to the wall and cant walk forward or jump! canu u maybe help me with this?
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Are all of your variables set up correctly (especially the layermasks)? :D Also remember that you can download the full project file over my discord server if you want :D
@christianbrandon2350
@christianbrandon2350 4 жыл бұрын
dave pls make a tutorial to make the weapon is not clipping into the walls when the weapon equip
@asiankidgamer
@asiankidgamer 4 жыл бұрын
Did you solve the problem yet? if you didn't, you could just add a collider to the weapon :)
@christianbrandon2350
@christianbrandon2350 4 жыл бұрын
No its can't its will bugging
@FGMatej
@FGMatej 3 жыл бұрын
you need to add a layer on the gun and call it "gun" then click on camera and then click on Culling Mask and select everytthing exept the gun. then add another camera and call it "GunCamera" on the Culling mask select only the gun. click on the Clear Flags in the GunCamera and select Dont clear
@soled_yt746
@soled_yt746 3 жыл бұрын
Trying to Invoke method: GunScript.ResetShot couldn't be called. can someone help me plz.
@NebulaDev
@NebulaDev 3 жыл бұрын
Amazing Video! Nice and clear, works well, and references everything in the comments. Thanks!
@KibensFG
@KibensFG 2 жыл бұрын
randomizing the spread x and y makes it so it only work correctly in certain camera angles, turning 90 degrees makes it only spread vertically(?), my fix was to add a random float z with the same ranges and add that to the new vector3 (so + new vector3(x,y,z)), also the bulletholes that spawn always point the same way no matter what direction you're shooting from. so now im trying to turn those holes in correlation to my main camera rotation, hope that'll work
@KibensFG
@KibensFG 2 жыл бұрын
Instantiate(bulletHoleGraphic, hitInfo.point, Quaternion.Euler(-180, playerCamera.localEulerAngles.y, 0)); kinda fixed the bullet hole issue but the holes will only look good if the wall you're shooting is perpendicular to the way you're looking.
@atlantisfigi7583
@atlantisfigi7583 2 жыл бұрын
@@KibensFG can you explain the playerCamera.localEulerAngles.y part, because if i do that it gives an error.
@Randomguy-op2hs
@Randomguy-op2hs 2 жыл бұрын
@@atlantisfigi7583 You still having that error?
@zontora7864
@zontora7864 3 жыл бұрын
OMG! THANK YOU SO MUCH! THIS DESERVES A LIKE, FOLLOW AND NOTIFICATIONS! THIS SERIOUSLY OPENED A WHOLE NEW WORLD FOR ME. IVE SEARCHED FOR MONTHS FOR A TUTORIAL LIKE THIS!
@reaporofdragon744
@reaporofdragon744 Жыл бұрын
with this tutorial .. im using multiple cameras so should i add the gun to all 4 cameras ???
@saulplays7961
@saulplays7961 4 жыл бұрын
Thanks when I do code their is always an error
@plaftrik8793
@plaftrik8793 3 жыл бұрын
LMAO Right
@grafee8584
@grafee8584 2 жыл бұрын
aah! there is a little problem with text thing text.SetText(bulletsLeft + " / " + magazineSize); 6:12 and ShootingAi (is there any vid or code for that!): 3:13
@Beta-zp5st
@Beta-zp5st 10 ай бұрын
you already download de textmexpro?
@grafee8584
@grafee8584 10 ай бұрын
​@@Beta-zp5stappreciate the answer after ONE YEAR of waiting
@jasongionis9454
@jasongionis9454 2 жыл бұрын
Hi! thank you for your script, i used a modified version of it, that i made based on yours for a while but having to detect which gun i was using to use the right stats was very counter-productive and not good for performance. I switched to an Interface based system but nevertheless, i have found no other good tutorial on youtube about this topic which is pretty wild, as shooter games are definetly the #1 genre right now. Anyhow even if I am not using your code anymore it still helped me out a ton in the prototype phase of my game as a good base to rely on. thanks!
@jcastro4553
@jcastro4553 2 жыл бұрын
Mind pasting your code here? I took this one but I have an error popping up and have know idea how to fix it as I just started code
@VrMurdoll
@VrMurdoll 4 жыл бұрын
oi the bullet hole effect isn't working its just spawning objects at 0,0,0
@VrMurdoll
@VrMurdoll 4 жыл бұрын
while waiting ive been messing with rigidbodys making them into the bulletholes and then watch as they spawn in box for fun
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
@@VrMurdoll That's strange, they should spawn exactly at your attack point :D Are you sure your attack point is a child of the player and moves with your gun?
@VrMurdoll
@VrMurdoll 4 жыл бұрын
@@davegamedevelopment yea B
@VrMurdoll
@VrMurdoll 4 жыл бұрын
but im not talking about the muzzle flash im talking about the bullet hole effect
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
@@VrMurdoll Oh sorry, my bad. In that case you need to check if your raycast is working properly, make a new Vector3 variable and when shooting the ray say: yourVariable = hit.Point Then have a look at your Vector3 in the inspector, if it's 0,0,0, then something is wrong with your raycast code :D
@foldupworks7153
@foldupworks7153 4 жыл бұрын
Hi thanks for the video, this is great, just having a bit of trouble with the shootingAI error but I will get there, I dont want to delete it I want to learn how I shoulf have it setup, should I be creating another script for enemy damage which would contain the shootingai namespace. I had a look over your discord but couldnt find anything, great discord btw
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Thanks a lot! :D So you just need to make another script called exactly "ShootingAi" and put this on whatever enemy you want to have. In the script make this function: public void TakeDamage(int damage) { health -= damage; if (health
@foldupworks7153
@foldupworks7153 4 жыл бұрын
@@davegamedevelopment Thats worked great, thanks for your great video and excellent support, I will recommend your channel to all!
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
@@foldupworks7153 Thank you so much man! :D
@Hxkuu_
@Hxkuu_ 4 жыл бұрын
@@davegamedevelopment It says health does not exist whyy?
@potatokato-chan3399
@potatokato-chan3399 4 жыл бұрын
@@davegamedevelopment is not working
@leralix98
@leralix98 2 жыл бұрын
Very usefull video ! You helped me a lot with my gun, but you also brought intersting ideas like the Invoke methods that will be usefull in other part of my games. Thanks a lot
@ironprime9937
@ironprime9937 4 жыл бұрын
What an amazing tutorial you made, you help me to practice and experiment more. I have one question: if I want to make a burst gun, I do need to code a script only for that gun am I might right?
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
No need for another script, just set the "bulletsPerTap" variable to something like 3, "timeBetweenShots" to about 0.1f and "timeBetweenShooting" to 0.5 :D
@ironprime9937
@ironprime9937 4 жыл бұрын
@@davegamedevelopment all right! Thank you so much.
@OhioTrollerGameDev
@OhioTrollerGameDev 2 ай бұрын
bro is brackeyes twin
@SkelebyteStudios
@SkelebyteStudios 4 жыл бұрын
Hey i'm getting an error it says "the type or namespace name 'CamShake' could no be found (ar you missing a using directive or an assembly reference?) is there any way you could help me fix this?
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
It simply means that you don't have the script called "CamShake". You can eighter follow along Brackeys tutorial about camera shake or just delete all lines with "CamShake" in them. Btw, same goes for the "EnemyAi" error :D
@SkelebyteStudios
@SkelebyteStudios 4 жыл бұрын
@@davegamedevelopment OK thanks for that
@IdentityYT
@IdentityYT 2 жыл бұрын
brackeys camera shake video is not working for me... how would i take out the camera shake?
@cinemacat4108
@cinemacat4108 3 жыл бұрын
Nice tutorial, thanks for the amazing content, but I have a question, isn't it better for shooting more than a one a bullet using a for loop
@sx6002
@sx6002 2 жыл бұрын
Hello, does anybody know how to fix this error? The type or namespace name 'CamShake' could not be found (are you missing a using directive or an assembly reference?)
@Joni-gv6kn
@Joni-gv6kn 4 жыл бұрын
I cant add a Script into my "Cam Shake", y tho?
@macaaris1018
@macaaris1018 3 жыл бұрын
Same problem
@eduardovolpatoreche6483
@eduardovolpatoreche6483 3 жыл бұрын
@@macaaris1018 you need to put the camshake script on the camera and then you put it in the gun script
@macaaris1018
@macaaris1018 3 жыл бұрын
@@eduardovolpatoreche6483 means this scripts works for you?
@eduardovolpatoreche6483
@eduardovolpatoreche6483 3 жыл бұрын
@@macaaris1018 so-so
@nonameman7114
@nonameman7114 3 жыл бұрын
For some reason the cam shake doesn’t do anything for me. There’s no effect at all
@descendlinktrs473
@descendlinktrs473 3 жыл бұрын
I keep getting an error which says that “the type it namespace name ‘ShootingAi’ could not be found (are you missing a using directive or an assembly reference” someone help
@ps5games821
@ps5games821 4 жыл бұрын
where can I get ShootingAI for your code because I get an error in Visual Studio?
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Eighter just delete the red-underlined lines or get the whole project file, there the ai should be set up :D
@chuadhrymohsin8944
@chuadhrymohsin8944 2 жыл бұрын
theres an error in named as camera shake reference not found
@FGMatej
@FGMatej 2 жыл бұрын
Create a script called CamShake and put this into it : kzbin.info/www/bejne/b3Kcqp1ugNOAbsU
@ericlassard9
@ericlassard9 3 жыл бұрын
wooaw thats vwery cool -Dani
@TerrorTarun
@TerrorTarun 4 жыл бұрын
Which key or mouse button you use to shot
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
The Left mouse button :D Input.GetKeyDown(KeyCode.Mouse0)
@booksforlife7903
@booksforlife7903 3 жыл бұрын
I've been doing Unity game development and learning C# for 43 days now and I could keep up with most of what you did, For me it was a great tutorial, though explaining things a little more would be better for me, because of my lack of exp. Though I am going to program and make games everyday for a year. Also I followed you and don't have any errors, but my gun isn't firing. So if you have any idea of what I did wrong that would really help. Thanks for your content and I can't wait to see more. Also I was wondering If you could make a tutorial showing how to make a map editor for a game?I can't find any videos for this online. Thanks again.
@nikolozmzhavanadze4557
@nikolozmzhavanadze4557 3 жыл бұрын
why there are not ShootingAi or CamShake when i am writting code?
@thedumbanimator25
@thedumbanimator25 4 жыл бұрын
Is it me or Dave's voice sounds like brackeys voice or Dave is brackey!?
@QuickPulseActive
@QuickPulseActive 4 жыл бұрын
i think dave is brackey
@hawthorn4623
@hawthorn4623 4 жыл бұрын
why is it saying - Assets\GunShoot.cs(24,12): error CS0246: The type or namespace name 'CamShake' could not be found (are you missing a using directive or an assembly reference?)
@isammonke4677
@isammonke4677 4 жыл бұрын
same thing here
@DavidAdochiti
@DavidAdochiti 4 жыл бұрын
u got good tags :)
@2014-b4o
@2014-b4o 4 жыл бұрын
one more thing how can i make bullet physics like battlefield guns and fortnite snipers when u shoot from far away u see the bullet falling down
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
You need to use real bullets instead of raycasts for this. Search on youtube for "Unity shooting bullets tutorial" :D
@2014-b4o
@2014-b4o 4 жыл бұрын
Dave / GameDevelopment thank u dave!
@samampa007
@samampa007 4 жыл бұрын
I tried making an animation for the reload function, which I put in the Reload Void, private void Reload() { reloading = true; Invoke("ReloadFinished", reloadTime); anim.Play("ReloadAmmo", 0, 0.0f); } My anim is: Public Animator anim. Should I change it to animation. I've also tried, if (Input.GetKeyDown(KeyCode.R) && bulletsLeft < magazineSize && !reloading) { anim.SetTrigger("Reload"); Reload(); } The animation doesn't come out how I animated it. My gun would be all over the screen.
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
The second version is exactly how I would code it, so I guess the problem is your animation :D
@gabrielx24_44
@gabrielx24_44 3 жыл бұрын
how can i fix the error " error CS0246: The type or namespace name 'CamShake' could not be found (are you missing a using directive or an assembly reference?)"?
@soled_yt746
@soled_yt746 3 жыл бұрын
Check if yhe name of your camera shake script is called CamShake.
@toad5664
@toad5664 4 жыл бұрын
i got an error saying: error CS0246: The type or namespace name 'CamShake' could not be found (are you missing a using directive or an assembly reference?)
@roanbeers
@roanbeers 4 жыл бұрын
I have the same error and i have aldo a error with ShootingAI i can put enemyAI there but i don’t no of that is the solution.
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
It's simply because you don't have the script called "CamShake", either you watch Brackeys tutorial about camera shake or you just delete all of the red-underlined lines :D (Also delete the "ShootingAi" lines :D)
@shikkuu8295
@shikkuu8295 4 жыл бұрын
@@davegamedevelopment Hey could you say me where you got that health script from thanks
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
​@@shikkuu8295 If you're talking about the "HealthBar" script, It's from the "simple health bar" asset (Asset store). :D If you're talking about the enemy damaging system, I made it myself, but you can download the full project file containing all scripts over my discord :D
@shikkuu8295
@shikkuu8295 4 жыл бұрын
Okay thanks but I have an other question if I am shooting against a wall the gameobject which is getting instigated is not in the right rotation it’s just Seeaales from one side could you help me
@VKHhenny
@VKHhenny 3 жыл бұрын
do you know where i can find a script tutorial with the take damage function?
@peteredmonds1712
@peteredmonds1712 4 жыл бұрын
I would like to use a model with this script on it as a prefab in my game. How would I connect the fpsCam and attackPoint components in code?
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Sorry for answering so late, sometimes I don't get notified... In void start you can say: fpsCam = GameObject.Find("NameOfTheObject").GetComponent(); same for the attack point but with .transform instead of GetComponent! :D
@bartjol5949
@bartjol5949 Жыл бұрын
I can't get it to work because it doesn't know the "ShootingAi" what should I do? What is the ShootingAi?
@tomassthg
@tomassthg Жыл бұрын
I Got The Same one and I don't know what to do. I think its saying we need a script called ShootingAi in the same GameObject we put the GunSystem Script in.
@bartjol5949
@bartjol5949 Жыл бұрын
@@tomassthg Yeah, I joined a discord server, they explained it all, I would do the same thing
@MGDMomoGameDev
@MGDMomoGameDev 4 жыл бұрын
Is there a version for 2d pls heeelp
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Maybe this helps: kzbin.info/www/bejne/rZyupJ9ngsuja68&ab_channel=Brackeys
@Nick-te6pz
@Nick-te6pz 2 жыл бұрын
Dude this is amazing it is so simple to understand I don't know how to thank you for this amazing script
@rooftopgaming5989
@rooftopgaming5989 4 жыл бұрын
Hi, I have a problem where the weapon scales according to the camera: for e.g when look up it will look longer and thinner, and when I crouch ( using your wallrun tutorial movement script) it becomes so flat. How do I fix this My rigid body on the gun is set to continuous speculative and extrapolate ( for the drop and pickup script ) and it is parented correctly ( Player : fps camera: Gun Container: Gun ) .
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
Normally this should fix it: www.unity3dtips.com/how-to-fix-objects-stretching-when-rotated/ Hope it works :D
@toad5664
@toad5664 4 жыл бұрын
i now have another error: error CS0111: Type 'GunSystem' already defines a member called 'ReloadFinished' with the same parameter types, hich means theres 2 of the same thing but i have checked through all of it
@theomggamer7514
@theomggamer7514 4 жыл бұрын
tag:enemy is not defined
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
You need to make a new Tag called "Enemy" first :D
@craigmankind8809
@craigmankind8809 2 жыл бұрын
@@davegamedevelopment How??
@sx6002
@sx6002 2 жыл бұрын
Hello, i was wondering do i need to apply a seperate script for takedamage() or is that my own script that i would make for enemy damage system
@that_kaii
@that_kaii 4 жыл бұрын
"and sorry ofc you have to use spread", well not if your playing tf2
@CSgamings
@CSgamings 3 жыл бұрын
the demoman has spread on his pipe
@geniusrealms
@geniusrealms 2 жыл бұрын
Hey I have a quest. How can I make the magazine finish. Instead of getting infinite ammo
@casualshox4972
@casualshox4972 4 жыл бұрын
There is no such a think as ShootingAi
@ihumbleyou
@ihumbleyou 4 жыл бұрын
having the same problem
@davegamedevelopment
@davegamedevelopment 4 жыл бұрын
​@@ihumbleyou "ShootingAi" is a script you don't have :D Just delete all lines containing "ShootingAi" and it should work fine!
@casualshox4972
@casualshox4972 4 жыл бұрын
@@davegamedevelopment ill try and Thx ı
@ihumbleyou
@ihumbleyou 4 жыл бұрын
@@davegamedevelopment ok thanks mate🤓😊
@jessemmvi3974
@jessemmvi3974 2 жыл бұрын
I don't get this part: 3:12 and you told me to ask in the comments :) I get an error in unity: The type or namespace name 'ShootingAi' could not be found... What do I need to do/change to make it work
@davegamedevelopment
@davegamedevelopment 2 жыл бұрын
"ShootingAi" is a Script you don't have, just delete any lines containing Shooting Ai :D
@dudleydelcy
@dudleydelcy 4 жыл бұрын
3:45 RigidBody Spread reference note
@rekutor9410
@rekutor9410 3 жыл бұрын
Hey uh i get this error in unity NullReferenceException: Object reference not set to an instance of an object GUN.Update () (at Assets/GUN.cs:37) at line 37 is this: text.SetText(bulletsLeft + " / " + magazineSize);
@Hxlip09xStickman
@Hxlip09xStickman 4 жыл бұрын
I need help my muzzle flash isn't appearing
@sausageman7055
@sausageman7055 4 жыл бұрын
First make the muzzle flash a child of the 3D Gun model, then on the particle system settings of the muzzle flash, turn "play on awake" on
Unity SINGLE, DOUBLE and LONG mouse click Tutorial || SkillBased Tutorials
4:46
Dave / GameDevelopment
Рет қаралды 10 М.
I Made Call of Duty Warzone in 48 Hours
8:50
UsmanDev
Рет қаралды 516 М.
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 67 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 34 МЛН
SHOOTING with BULLETS + CUSTOM PROJECTILES || Unity 3D Tutorial (#1)
9:25
Dave / GameDevelopment
Рет қаралды 207 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 676 М.
ADD ARMS TO YOUR GAME - EASIEST WAY (Unity3D)
15:22
JonDevTutorials
Рет қаралды 65 М.
How I Made a Satisfying FPS Controller
4:38
Lejynn
Рет қаралды 142 М.
Shooting with Raycasts - Unity Tutorial
13:41
Brackeys
Рет қаралды 1,9 МЛН
He said I Couldn't Make a 3D Game... So I Made One!
10:29
Dani
Рет қаралды 9 МЛН
FULL PICK UP & DROP SYSTEM for WEAPONS or ITEMS || Unity3d Tutorial
5:45
Dave / GameDevelopment
Рет қаралды 191 М.
Unity FPS Movement Tutorial by Dani  |  Karlson Parkour FPS Controller
8:36
DanisTutorials
Рет қаралды 1,1 МЛН
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 6 МЛН