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 Жыл бұрын
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 Жыл бұрын
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
@Siuuu9748 ай бұрын
kannst du auch deutsch?
@Andy6h1l4 жыл бұрын
I found Brakeys' second channel! Woohoo!
@mahmoud-quran4 жыл бұрын
Haha he sounds so much like him
@Werner-sv2le3 жыл бұрын
I was very hopeful for a second until I found out if wasn't him
@ruleamormedia37473 жыл бұрын
Thought the voice was familiar
@diliupg3 жыл бұрын
This is him, spread the word.
@infinixs46002 жыл бұрын
Absolutely me too
@haydenmcturk23292 жыл бұрын
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-vn5fd2 жыл бұрын
bless you! I was looking through the comments for these very words
@RiceR6art-l9k Жыл бұрын
how do i get the muzzle flash to be set to play on awake?
@RiceR6art-l9k Жыл бұрын
nevermind i found out how
@RiceR6art-l9k Жыл бұрын
bullet holes aren't appearing though?
@raunaksharma863811 ай бұрын
Thnx a lot brother your comment was a lot helpful .
@dellusenew1236 ай бұрын
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
@krzaczastyyt65475 ай бұрын
I Love you
@--l6070Ай бұрын
Also it is better to create an empty child of the gun and put it to the end of the barrel.
@koolgoose4 жыл бұрын
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!
@davegamedevelopment4 жыл бұрын
Thanks a lot man! :D
@smitasushilbhegde36552 жыл бұрын
But for me its still gonna go to 2x
@davegamedevelopment4 жыл бұрын
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?
@ahmadgamal95874 жыл бұрын
i need a weapon bob for my fps can make a video for it
@davegamedevelopment4 жыл бұрын
@@ahmadgamal9587 Thanks for the suggestion! :D But not quite sure yet if I'll do a tutorial about it.
@davegamedevelopment4 жыл бұрын
@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
@davegamedevelopment4 жыл бұрын
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
@taylormarinescu8054 жыл бұрын
I could keep up
@sama-vh8ge2 жыл бұрын
This channel has single handedly helped me relearn c# and unity. Fantastic resource, straight to the point.
@davegamedevelopment2 жыл бұрын
That's awesome to hear! Thanks a lot!
@JVC0B4 жыл бұрын
Very clean explanation! You had a lot of information packed into a short amount of time, which was great! Keep it up :)
@davegamedevelopment4 жыл бұрын
Chillehh Thank you! :D
@davegamedevelopment Жыл бұрын
@OPchees Thanks man, appreciate it!!
@MkbballAnimations Жыл бұрын
@@davegamedevelopment hi
@obnoxiousnoise74112 жыл бұрын
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
@SleepDreamDev3 ай бұрын
hows it going with the code bro
@obnoxiousnoise74113 ай бұрын
@@SleepDreamDev It was actually going really well but I've had to take an extended hiatus from coding cuz of my job
@SleepDreamDev3 ай бұрын
@@obnoxiousnoise7411 what where you working on?
@obnoxiousnoise74113 ай бұрын
@@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
@trader99262 жыл бұрын
We all know you are just brackeys doing his Elizabeth holmes voice impression. Just kidding you’re awesome great videos man very educational!
@davegamedevelopment2 жыл бұрын
Thanks a lot!
@1nput_02 жыл бұрын
amazing and straight forward!! definitely will recommend this to anyone who needs a simple and useful gun system. good work :D
@davegamedevelopment2 жыл бұрын
Thanks a lot!
@PostcardFromADream4 жыл бұрын
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!
@davegamedevelopment4 жыл бұрын
I feel you, coding is so strange sometimes^^ But glad it helped you! :D
@Lazyy-Gamer Жыл бұрын
@@davegamedevelopment bro but i getting and error of "ShootingAi" could not be found
@1qqa1sddlpfds Жыл бұрын
me to but why ?@@Lazyy-Gamer
@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 Жыл бұрын
that's was helpful thanks@@zy2684
@divyanshpathak25064 жыл бұрын
Man You are EPIC But please upload more tutorial(Noobs really need it-just like me)
@davegamedevelopment4 жыл бұрын
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
@acemoistman4 жыл бұрын
@@davegamedevelopment Totally agree keep em comin bro you make it super easy to understand. Somehow faster than Brackeys
@M1nozVL4 жыл бұрын
yeees
@ipga133 жыл бұрын
i only get the type or namespace ShootingAi could not be found(are you missing a using directive or an assembly reference?)
@Meekailonyt3 жыл бұрын
@@ipga13 you have to make a script called shootingai and have a damage function in it
@DucatChannel3 жыл бұрын
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?
@sajflatter3 жыл бұрын
@BurliestStorm94 replace it with Vector3 (0,x,y) and it will be tip-top
@FoxyGame20062 жыл бұрын
@@sajflatter No, to solve this make float z like the x and y with the random method, and place these like (x, y, z)
@marcopadeiro30213 жыл бұрын
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
@ItzBetrayed3 жыл бұрын
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!
@wtmftproductions3 жыл бұрын
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.
@daoollaa2 жыл бұрын
can you please tell me more about it? Or better yet, an example
@wtmftproductions2 жыл бұрын
@@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.
@wtmftproductions2 жыл бұрын
In Unity, any Vector variable has a member function for Normalize
@wtmftproductions2 жыл бұрын
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 Жыл бұрын
for some reason when i shoot the bullet hole appears at 0,0,0 instead of where the raycast go's
@ThisAccountIsDead3338 ай бұрын
Did you ever find a solution to this 😩😩😩
@terrydafunny70777 ай бұрын
@@ThisAccountIsDead333 have you found one?
@Magaelcrack4 жыл бұрын
really good, I also like making game so this is really helpful! I personally like more scriptableobjects but each one has its own way!
@davegamedevelopment4 жыл бұрын
Thanks a lot! :D
@gaminganimator-qp2ir4 жыл бұрын
@@davegamedevelopment where to put the script
@davegamedevelopment4 жыл бұрын
@@gaminganimator-qp2ir On your gun :D
@gaminganimator-qp2ir4 жыл бұрын
making games is more fun then playing games
@blokkiesotto58542 жыл бұрын
@@gaminganimator-qp2ir trueeeeeeeeeee
@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);
@Adrakxys2 жыл бұрын
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 Жыл бұрын
YOU LEGENDDDD THANKS SO MUCHHHH
@goofyahhmoron1141 Жыл бұрын
did you fix the bullets going to 0,0,0??
@renky_ren Жыл бұрын
OMFG thank you, finally i fix the muzzle flash issue
@terrydafunny70777 ай бұрын
@@goofyahhmoron1141 have you managed to fix btw
@lukekennedy73407 ай бұрын
@@terrydafunny7077 i managed to fix it by spawning a wall and tag it as enemy,
@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-un1ey4 жыл бұрын
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?
@GianniPapetti4 жыл бұрын
You have to create that script first
@GianniPapetti4 жыл бұрын
@@kansaslml7796 i don't he made a video of that, but all i can presume is that he made another script called ShootinAi
@OrangutanMonky4 жыл бұрын
@@GianniPapetti what to write in that script
@GianniPapetti4 жыл бұрын
@@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
@couchwow4 жыл бұрын
if you dont have one, delete it, the code is useless and unity is clueless on how to use it.
@hinthujanthiagarajah19754 жыл бұрын
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); }
@davegamedevelopment4 жыл бұрын
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
@hinthujanthiagarajah19754 жыл бұрын
@@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 :)
@davegamedevelopment4 жыл бұрын
@@hinthujanthiagarajah1975 Ah your code is a lot cleaner! :D I forgot about the "isInvoking" bool... Thanks for sharing!
@MkbballAnimations Жыл бұрын
@@hinthujanthiagarajah1975 hi
@konamisenpai8018 Жыл бұрын
Hello can you help me. I don't know which line of the code I will paste the fix
@Nviius562 жыл бұрын
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));
@blitzzyboi30122 жыл бұрын
Thank you!!!
@malachi6798 Жыл бұрын
my gun don't shoot
@uphjo6969 Жыл бұрын
it clips with stuff :(
@logan_Makegames Жыл бұрын
dont work
@TETE Жыл бұрын
shemogevle
@IrfuTuber2 жыл бұрын
"Yes" looks pretty Fun to Shoot With!
@miragenegs2 жыл бұрын
Great tutorial! one question on line 25 there is an error that states there is no such thing as camshake what do i do
@Fillyshejay2 жыл бұрын
im having the same problem man
@vbai56642 жыл бұрын
Is says CamShake sould nt be found help pls!!!
@TheJungaBoon4 жыл бұрын
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.
@aleksp87683 жыл бұрын
Same
@Walter_Hartwell_White3562 жыл бұрын
i have been reading the comments and you really help the people! so here is your like and my sub, great video
@davegamedevelopment2 жыл бұрын
Thank a lot!
@samisalama30332 жыл бұрын
if you are helping can you help me and tell me how to get CamShake?
@MKI-eq8ok2 жыл бұрын
@@samisalama3033 there is a video in the desc showing how to do it
@selahattinturan14193 жыл бұрын
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?)
@Boxply3 жыл бұрын
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
@AZASeraph3 жыл бұрын
I got the same error
@Walter_Hartwell_White3562 жыл бұрын
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
@davegamedevelopment2 жыл бұрын
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_White3562 жыл бұрын
@@davegamedevelopment thx dude! i solved it :D you are awesome
@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?
@miguelclemente49792 жыл бұрын
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
@mixedtrigenito2 жыл бұрын
replace it with Vector3 (0,x,y) and it will be tip-top
@connorrice76102 жыл бұрын
@@mixedtrigenito where do I replace 0,0,0 with vector3?
@LandonIsbell299 ай бұрын
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.
@ThisAccountIsDead3338 ай бұрын
@@LandonIsbell29that did not fix it for me :( mine was already 100
@LandonIsbell298 ай бұрын
@@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.
@rincon1753 жыл бұрын
i have a problem when i shoot the muzzle flash doesn't stay at the attack point when I'm moving around
@Galepic3 жыл бұрын
did u solve it? im having the same issue
@liptojaj3 жыл бұрын
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?
@mincha99993 жыл бұрын
can i get the code man?
@pelztierssohn81982 жыл бұрын
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?
@pizzaslijm21142 жыл бұрын
Just delete the line, it is only if you have a script for shooting AI to let them take damage!
@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
@TheRealSnowyGuy3 жыл бұрын
OMG THANKS, I tried making my own script and didn't get it a bit close and thanks to you I can!
@fatdumduck3 жыл бұрын
Dave : says 15 times in th video the word "stuff" to discribe things Me : Understand every single "stuff" he is talking about cOmUniCAtIon
@SensibleStuff3 жыл бұрын
Hello... ~ from Sensible *Stuff*
@accountdisbanded3 жыл бұрын
@@SensibleStuff goodbye from qapch
@yogaagustina65014 жыл бұрын
really good tutorial mate. simple and clear explanation. keep up the good work. can't wait for your next tutorial
@SirJustinn4 жыл бұрын
Can you show me the script
@Flyomega3 жыл бұрын
Mec c'est incroyable ce carry j'espère que tu as ou que tu vas avoir une vie incroyable. Juste merci ;)
@salesbanglore19263 жыл бұрын
Nani
@jellybeans77292 жыл бұрын
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
@ghlow63462 жыл бұрын
For anyone who's bullet holes are not spawning, remove all instances of whatIsEnemy from GunSystem.cs and it should work fine.
@Jay___ink2 жыл бұрын
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!
@griffinbrooks67484 жыл бұрын
how do you make the bullet hole graphic where you hit?
@Airsickword4 жыл бұрын
was about to comment that you sound like Brackeys, then it clicked
@dragonman78063 жыл бұрын
same bruh
@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
@ethancossett73183 жыл бұрын
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 Жыл бұрын
are you still having this issue?
@konamisenpai8018 Жыл бұрын
@@qShaun me please help
@IAShepherd.p11 ай бұрын
@@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 Жыл бұрын
Super new to Unity. Love the channel!
@zabby134 жыл бұрын
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?
@davegamedevelopment4 жыл бұрын
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
@christianbrandon23504 жыл бұрын
dave pls make a tutorial to make the weapon is not clipping into the walls when the weapon equip
@asiankidgamer4 жыл бұрын
Did you solve the problem yet? if you didn't, you could just add a collider to the weapon :)
@christianbrandon23504 жыл бұрын
No its can't its will bugging
@FGMatej3 жыл бұрын
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_yt7463 жыл бұрын
Trying to Invoke method: GunScript.ResetShot couldn't be called. can someone help me plz.
@NebulaDev3 жыл бұрын
Amazing Video! Nice and clear, works well, and references everything in the comments. Thanks!
@KibensFG2 жыл бұрын
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
@KibensFG2 жыл бұрын
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.
@atlantisfigi75832 жыл бұрын
@@KibensFG can you explain the playerCamera.localEulerAngles.y part, because if i do that it gives an error.
@Randomguy-op2hs2 жыл бұрын
@@atlantisfigi7583 You still having that error?
@zontora78643 жыл бұрын
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 Жыл бұрын
with this tutorial .. im using multiple cameras so should i add the gun to all 4 cameras ???
@saulplays79614 жыл бұрын
Thanks when I do code their is always an error
@plaftrik87933 жыл бұрын
LMAO Right
@grafee85842 жыл бұрын
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-zp5st10 ай бұрын
you already download de textmexpro?
@grafee858410 ай бұрын
@@Beta-zp5stappreciate the answer after ONE YEAR of waiting
@jasongionis94542 жыл бұрын
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!
@jcastro45532 жыл бұрын
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
@VrMurdoll4 жыл бұрын
oi the bullet hole effect isn't working its just spawning objects at 0,0,0
@VrMurdoll4 жыл бұрын
while waiting ive been messing with rigidbodys making them into the bulletholes and then watch as they spawn in box for fun
@davegamedevelopment4 жыл бұрын
@@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?
@VrMurdoll4 жыл бұрын
@@davegamedevelopment yea B
@VrMurdoll4 жыл бұрын
but im not talking about the muzzle flash im talking about the bullet hole effect
@davegamedevelopment4 жыл бұрын
@@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
@foldupworks71534 жыл бұрын
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
@davegamedevelopment4 жыл бұрын
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
@foldupworks71534 жыл бұрын
@@davegamedevelopment Thats worked great, thanks for your great video and excellent support, I will recommend your channel to all!
@davegamedevelopment4 жыл бұрын
@@foldupworks7153 Thank you so much man! :D
@Hxkuu_4 жыл бұрын
@@davegamedevelopment It says health does not exist whyy?
@potatokato-chan33994 жыл бұрын
@@davegamedevelopment is not working
@leralix982 жыл бұрын
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
@ironprime99374 жыл бұрын
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?
@davegamedevelopment4 жыл бұрын
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
@ironprime99374 жыл бұрын
@@davegamedevelopment all right! Thank you so much.
@OhioTrollerGameDev2 ай бұрын
bro is brackeyes twin
@SkelebyteStudios4 жыл бұрын
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?
@davegamedevelopment4 жыл бұрын
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
@SkelebyteStudios4 жыл бұрын
@@davegamedevelopment OK thanks for that
@IdentityYT2 жыл бұрын
brackeys camera shake video is not working for me... how would i take out the camera shake?
@cinemacat41083 жыл бұрын
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
@sx60022 жыл бұрын
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-gv6kn4 жыл бұрын
I cant add a Script into my "Cam Shake", y tho?
@macaaris10183 жыл бұрын
Same problem
@eduardovolpatoreche64833 жыл бұрын
@@macaaris1018 you need to put the camshake script on the camera and then you put it in the gun script
@macaaris10183 жыл бұрын
@@eduardovolpatoreche6483 means this scripts works for you?
@eduardovolpatoreche64833 жыл бұрын
@@macaaris1018 so-so
@nonameman71143 жыл бұрын
For some reason the cam shake doesn’t do anything for me. There’s no effect at all
@descendlinktrs4733 жыл бұрын
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
@ps5games8214 жыл бұрын
where can I get ShootingAI for your code because I get an error in Visual Studio?
@davegamedevelopment4 жыл бұрын
Eighter just delete the red-underlined lines or get the whole project file, there the ai should be set up :D
@chuadhrymohsin89442 жыл бұрын
theres an error in named as camera shake reference not found
@FGMatej2 жыл бұрын
Create a script called CamShake and put this into it : kzbin.info/www/bejne/b3Kcqp1ugNOAbsU
@ericlassard93 жыл бұрын
wooaw thats vwery cool -Dani
@TerrorTarun4 жыл бұрын
Which key or mouse button you use to shot
@davegamedevelopment4 жыл бұрын
The Left mouse button :D Input.GetKeyDown(KeyCode.Mouse0)
@booksforlife79033 жыл бұрын
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.
@nikolozmzhavanadze45573 жыл бұрын
why there are not ShootingAi or CamShake when i am writting code?
@thedumbanimator254 жыл бұрын
Is it me or Dave's voice sounds like brackeys voice or Dave is brackey!?
@QuickPulseActive4 жыл бұрын
i think dave is brackey
@hawthorn46234 жыл бұрын
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?)
@isammonke46774 жыл бұрын
same thing here
@DavidAdochiti4 жыл бұрын
u got good tags :)
@2014-b4o4 жыл бұрын
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
@davegamedevelopment4 жыл бұрын
You need to use real bullets instead of raycasts for this. Search on youtube for "Unity shooting bullets tutorial" :D
@2014-b4o4 жыл бұрын
Dave / GameDevelopment thank u dave!
@samampa0074 жыл бұрын
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.
@davegamedevelopment4 жыл бұрын
The second version is exactly how I would code it, so I guess the problem is your animation :D
@gabrielx24_443 жыл бұрын
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_yt7463 жыл бұрын
Check if yhe name of your camera shake script is called CamShake.
@toad56644 жыл бұрын
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?)
@roanbeers4 жыл бұрын
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.
@davegamedevelopment4 жыл бұрын
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)
@shikkuu82954 жыл бұрын
@@davegamedevelopment Hey could you say me where you got that health script from thanks
@davegamedevelopment4 жыл бұрын
@@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
@shikkuu82954 жыл бұрын
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
@VKHhenny3 жыл бұрын
do you know where i can find a script tutorial with the take damage function?
@peteredmonds17124 жыл бұрын
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?
@davegamedevelopment4 жыл бұрын
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 Жыл бұрын
I can't get it to work because it doesn't know the "ShootingAi" what should I do? What is the ShootingAi?
@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 Жыл бұрын
@@tomassthg Yeah, I joined a discord server, they explained it all, I would do the same thing
@MGDMomoGameDev4 жыл бұрын
Is there a version for 2d pls heeelp
@davegamedevelopment4 жыл бұрын
Maybe this helps: kzbin.info/www/bejne/rZyupJ9ngsuja68&ab_channel=Brackeys
@Nick-te6pz2 жыл бұрын
Dude this is amazing it is so simple to understand I don't know how to thank you for this amazing script
@rooftopgaming59894 жыл бұрын
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 ) .
@davegamedevelopment4 жыл бұрын
Normally this should fix it: www.unity3dtips.com/how-to-fix-objects-stretching-when-rotated/ Hope it works :D
@toad56644 жыл бұрын
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
@theomggamer75144 жыл бұрын
tag:enemy is not defined
@davegamedevelopment4 жыл бұрын
You need to make a new Tag called "Enemy" first :D
@craigmankind88092 жыл бұрын
@@davegamedevelopment How??
@sx60022 жыл бұрын
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_kaii4 жыл бұрын
"and sorry ofc you have to use spread", well not if your playing tf2
@CSgamings3 жыл бұрын
the demoman has spread on his pipe
@geniusrealms2 жыл бұрын
Hey I have a quest. How can I make the magazine finish. Instead of getting infinite ammo
@casualshox49724 жыл бұрын
There is no such a think as ShootingAi
@ihumbleyou4 жыл бұрын
having the same problem
@davegamedevelopment4 жыл бұрын
@@ihumbleyou "ShootingAi" is a script you don't have :D Just delete all lines containing "ShootingAi" and it should work fine!
@casualshox49724 жыл бұрын
@@davegamedevelopment ill try and Thx ı
@ihumbleyou4 жыл бұрын
@@davegamedevelopment ok thanks mate🤓😊
@jessemmvi39742 жыл бұрын
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
@davegamedevelopment2 жыл бұрын
"ShootingAi" is a Script you don't have, just delete any lines containing Shooting Ai :D
@dudleydelcy4 жыл бұрын
3:45 RigidBody Spread reference note
@rekutor94103 жыл бұрын
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);
@Hxlip09xStickman4 жыл бұрын
I need help my muzzle flash isn't appearing
@sausageman70554 жыл бұрын
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