BRUH, YOU CAN'T JUST STOP UPLOADING MAN. At least continue with this series. PLEASE CONTINUE WITH THIS SERIES
@ArmTheNub3 жыл бұрын
Thank you from the bottom of my heart. I've been searching and tried to write proper script that makes bullets ricochet and your videos help me develop a proper script using your methods. The stress was immeasurable and this is a big had taken all of it away. Again thank you.
@jackjacky45874 жыл бұрын
Ur unity tutorials are honestly one of the best in KZbin, very detailed 👏🏻👍👍
@davegamedevelopment4 жыл бұрын
Thank you so much! Glad you like them! :D
@Maskeowl3 жыл бұрын
@@davegamedevelopment helo i need help i wannto add bullethole walls how i can do that?
@thelegendarymushroom80 Жыл бұрын
@@Maskeowl just an idea and I have never worked with that before, but try and see if you can add Pro Builder with that idea of yours.
@meiers86372 жыл бұрын
If someone has the problem that the explotion repeats infinitely when it impacts, at least i solved it by selecting the explotion prefab and opening it on the inspector right on the upper right where it says open, and then unchecking the looping section in all three sub parts of the prefab.
@raymondvaldepenas62454 жыл бұрын
If you have problems with your bullet which are not detected for collision with a game object with a "whatIsEnemies" Layer mask set with a tag of Enemy... try using continuous dynamic as a collision detection... :D
@flipsareflippingfun29714 жыл бұрын
I just want to say these tutorials are absolutely helpful. They are also not too fast for me unlike some ppl say, for more experienced coders it is fine and you can pause anyway
@misterdoctor28724 жыл бұрын
Can do a tutorial on how to make animations for the weapons and how to implement them??
@davegamedevelopment4 жыл бұрын
Thanks for the idea :D Maybe I'll do that, but I'm not sure, I normally decide spontaneously :D
@gaminganimator-qp2ir4 жыл бұрын
kzbin.info/www/bejne/gF62Yn-hbL-Emrc here ya go
@alexbasics22602 жыл бұрын
Hey dave! I have a problem and when the projectile collides with something it explodes but after exploding the explosion effect its still there! and I dont know what to do... Could you help me? Nice vid btw!!! :)
@retlyfast4816 Жыл бұрын
Do you still need help? I found way 1 uncheck loop (if you are using unity particle pack dont forget to uncheck child too) 2 Under particle system there is stop action change to destory
@carterearles95284 жыл бұрын
Thank you so much for what you do! I would have an it if like 1 if it wasn’t for these videos. I did so much research on invoke, and couldn’t find anything. Then you explain it in like 5 seconds in a video!
@fildaletnany4 жыл бұрын
I have a problem. After the explosion, the script destroys the bullet and it says that the gameObject doesnt exist. Did i set something wrong? Edit: solved it, i had to use the prefabs of my bullets instead of the prespawned.
@Mike-de2yt2 жыл бұрын
same, thanks you helped me out
@whitesheep14172 жыл бұрын
I have the problem that my bullet gets destroyed like it should do but my explosion keeps coming over and over again and 1 bullets spawns 6 explosions for some reason. Do you guys have any idea to solve this?
@bobj12342 жыл бұрын
how do you do that?
@cubercube605 Жыл бұрын
@@whitesheep1417 have youo found it
@whitesheep1417 Жыл бұрын
@@cubercube605 nope but i dont need it anymore i do not make games right now
@stevenjuana39204 жыл бұрын
Yet Again, Great Tutorial!
@FarseerAnimation3 жыл бұрын
This is very detailed and concise, however I think it would really help the viewer if there was a little bit of a pause between actions. It can just be a little overwhelming for someone who is learning if you move on so quickly.
@friendlyhoovy55973 жыл бұрын
you are a saint my dude
@pizzapepperoni25922 жыл бұрын
Thanks for you tutorial bro!
@MrFyce3 жыл бұрын
there's no mention of custom projectiles as stated in the title?!
@Sp8dezz4 жыл бұрын
help please my explosion effect keeps looping when i shoot a bullet any help would be appreciated !.Thx in advance :)
@davegamedevelopment4 жыл бұрын
Open the bullet effect and in the particle system component turn off "loop"
@Sp8dezz4 жыл бұрын
@@davegamedevelopment thx it helped
@rayyan78184 жыл бұрын
@@Sp8dezz how do i do that?
@pebble89114 жыл бұрын
@@rayyan7818 left click on your particle effect > inspection > loop off
@Dogmut4 жыл бұрын
@@pebble8911 I've done this but the effect is still looping?
@bauzi65494 жыл бұрын
Hello there! I am glad i found you Channel, your videos are really well made. Keep it up! Everything is working for me so far, ecxept that the bullets bounce on Walls, but always on a 90 degree angle. Do you know how this problem can be solved? Other then that, thanks for the Tutorial!
@bauzi65494 жыл бұрын
Oh, i found my Problem myself! I used a Cube instead of a Sphere as a bullet.
@davegamedevelopment4 жыл бұрын
@@bauzi6549 K, glad it works now! :D
@crisiman972 жыл бұрын
The link for the gunprojectile tutorial is blocked. How can i get it another way
@Ferenc-Racz4 жыл бұрын
He sounds as Brackeys :D
@L0rdBud4 жыл бұрын
if only, rip Brakeys
@atsurao4 жыл бұрын
ye i noticed too, rip
@rayyan78184 жыл бұрын
I have a problem sometimes the bullet shoots above or to the side of the attackpoint any fix?
@IQWLR4 жыл бұрын
i have a problem it says "the variable bullet of projectileguntutorial has not been assigned" your reply would be much appreciated
@davegamedevelopment4 жыл бұрын
You probably didn't assign the correct bullet prefab :D You need to take the one directly from the Assets folder and drag to to your script. Don't take the one inside of your scene (Because it gets destroyed when starting the game) :D
@alsafah27274 жыл бұрын
Dave / GameDevelopment oh thank you very much I’m the same person just on different account
@davegamedevelopment4 жыл бұрын
@@alsafah2727 haha ok :D
@thesqwisher75432 жыл бұрын
How do I stop the explosion from repeating when it hits a surface?
@davegamedevelopment2 жыл бұрын
Destroy the projectile
@bennydaboy69844 жыл бұрын
Sorry to bother you again but it sometimes bounces away when i have it on 0 bounciness and explode on touch
@davegamedevelopment4 жыл бұрын
Is the rigidbody set on "continuous" and "extrapolate" ? :D
@bennydaboy69844 жыл бұрын
@@davegamedevelopment Never mind I fixed it by adding this script to the bullet using System.Collections; using System.Collections.Generic; using UnityEngine; public class Destroy : MonoBehaviour { [Header("Unity Setup")] public ParticleSystem immpactEffect; private void OnCollisionEnter(Collision collision) { if (collision.collider.CompareTag("ground")) { Die(); } } void Die() { Instantiate(immpactEffect, transform.position, Quaternion.identity); Destroy(gameObject); } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } }
@gaminganimator-qp2ir4 жыл бұрын
@@bennydaboy6984 are u new to unity lol
@bennydaboy69844 жыл бұрын
@@gaminganimator-qp2ir is that ment to be joke or...
@gaminganimator-qp2ir4 жыл бұрын
@@bennydaboy6984 nah just wanted to murder someone
@kandy51292 жыл бұрын
Hi there. I have a question about the bullet. Once the bullet lifetime is over it just doesn't wanna shoot. The error i'm getting is GameObject has been destroyed but you are still trying to access it. How do I make it so that only the currentBullet is destroyed and not the actual bullet itself?
@Waltr_Black2 жыл бұрын
ayo same idk how to fix it...
@thelegendarymushroom80 Жыл бұрын
@kandy5129 , @luckyRoblox You need to create a prefab of the bullet and put that into the bullet slot of the gun! To make a prefab of the bullet object, simply drag and drop the bullet object down into the Project window. Then take that object (from the Project window you just created) and drag it into the slot.
@thelegendarymushroom80 Жыл бұрын
@@Waltr_Black :D check my comment
@Waltr_Black Жыл бұрын
@@thelegendarymushroom80 tysm bro
@thelegendarymushroom80 Жыл бұрын
@@Waltr_Black always bro!
@AldinCraft4 жыл бұрын
Wow nice
@davegamedevelopment4 жыл бұрын
AldinCraft Thanks!
@KaijuMike2 жыл бұрын
howdy. I've been using your guides to help me out with a school project, but I seem to run into a problem related to damage. I set the health of an enemy to 300 and the player at 100. both of their bullets have been set to 25 damage, but they do much more. the enemy kills the player in one hit and the player kills the enemy in one hit. (looking at the inspector, the enemy goes from 300 health to -400 to -525) maybe it was something that I did wrong related to the health ints? I could really use some help to figure out what I did wrong.
@KaijuMike2 жыл бұрын
figured out a part of it. for some reason, having the life time make it explode at the end did a lot more damage for some reason. also having the collisions set to 1 or 0. with collisions at 2 and changing when from explode to delay when max life hits 0, the enemies don't do friggin 30x the damage. they still do more than 25, but now it's only a consistent 50.
@davegamedevelopment2 жыл бұрын
As long as it's consistent, it's usable :D If it still bothers you though make sure to debug how often the TakeDamage function gets called (it's probably 2 times), then figure out from where it's called exactly and use some kind of bool/timer that makes sure you can't call the function twice within like 0.1 seconds
@catman74742 жыл бұрын
yo you just got to take off the Invoke("Delay", 0.05f); and put Delay(); or just make it faster what its doing is its hitting multiple times
@maxsoto60153 жыл бұрын
how do u make the particle effect disssapear from the hierarchy after the explosion
@YunaHelloHello3 жыл бұрын
Had the same issue, here's my fix. When you instantiate your explosion in void Explode, you can store it as a game object; such as "GameObject impactGO = Instantiate(explosion, transform.position, Quaternion.identity); " where impactGO is the temporary variable name I gave it. Then after the Invoke method, you can put in "Destroy(impactGO, time)". This should destroy the Instantiated explosions after your set time. You can set the time to however long you want the clones to last, but I would suggest keeping it longer than the Invoke method time.
@lokosstratos7192Ай бұрын
thank you!
@BertelsZera4 жыл бұрын
I have a problem. I set my lifetime to 10 seconds and when that 10 seconds end I can't shoot anymore, It says that the object has been destroyed buy I'm still trying to access it. Can anyone help?
@davegamedevelopment4 жыл бұрын
You need to make a prefab out of your projectile, and then assign the real prefab from your Assets folder (not the projectile from your scene, because it gets destroyed after 10 seconds) :D
@watercat12484 жыл бұрын
just realize i dont konw haw to make the ammo to destroy wean the teach the wall i try your ammo system to see if have properly for this
@gaminganimator-qp2ir4 жыл бұрын
not mine but here ya its from benny da boy using System.Collections; using System.Collections.Generic; using UnityEngine; public class Destroy : MonoBehaviour { [Header("Unity Setup")] public ParticleSystem immpactEffect; private void OnCollisionEnter(Collision collision) { if (collision.collider.CompareTag("ground")) { Die(); } } void Die() { Instantiate(immpactEffect, transform.position, Quaternion.identity); Destroy(gameObject); } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } }
@ogWeener4 жыл бұрын
hi bro.... i have a problem in my game with shooting... if I shoot at an object, the bullet flies around the object and flies in a different direction.
@atsurao4 жыл бұрын
me too did u find a way to fix it?
@ogWeener4 жыл бұрын
@@atsurao no 😅
@atsurao4 жыл бұрын
@@ogWeener oh, if you don't mind me asking did you find a way to do this in a different way or are you stuck just as I am?
@ogWeener4 жыл бұрын
@@atsurao yeah😂, I'm just stuck and try to find the way to fix it
@ogWeener4 жыл бұрын
Okey, I think... I could create server for all people which have this problem
@whitesheep14172 жыл бұрын
I have problems with damaging my enemys can you make a video on that topic please?
@marcamooo2 жыл бұрын
hey i was wondering if it was possible to just use the recoil part of the script? I wanted to use this type of recoil to try and mimic a rocket jumping type feature in my game but i have no idea how and when i tried this tutorial out, i noticed that there was a knockback like recoil. I dont know a whole lot about unity and c# so could you help me with using the same knockback as u do you in the projectile gun script? Thanks!
@brunomuller63564 жыл бұрын
hey dave i am working on a 3d shooter but everytime i hit something it says Tag: Enemy is not defined. do u have a solution XD
@davegamedevelopment4 жыл бұрын
Did you declare the tag first? :D Inside of the Unity inspector you need to open the tag list and make a new Tag called "Enemy", then put all of your enemies in there :D
@Rabudia.4 жыл бұрын
my bullets are not moving how i add a force to my bullet?
@Zebonsh4 жыл бұрын
Idk?
@zypherone2 жыл бұрын
They aren’t moving because they might be kinematic
@sanjayrajasree7914 жыл бұрын
My enemy damage function is not working, can anyone tell me?
@clinton20984 жыл бұрын
Hi guys, im trying to use this system but when the explosion and muzzle flash effect are played they continue playing and i cannot figure away to destroy them in game, it would be really helpful if someone could help me out. Thankyou.
@haydenkelley98063 жыл бұрын
Im alittle late and you might have figured this out, but, you need to turn off looping
@AZASeraph3 жыл бұрын
Hey I'm late so probably can't help u but turn looping off
@clinton20983 жыл бұрын
@@AZASeraph lol yeah a Lil late, but thanks for helping out
@Usajz4 ай бұрын
I have problem with recoil. It doesnt work and all and im not sure if i should add the rigidbody to empty object (folder) with Player or to the cyllinder.
@ImnotAbelsuni348 ай бұрын
Hey, i have a problem where my bullets spawn at a random position and i don't know why... There are no errors or anything.
@Hyphen33723 жыл бұрын
one question can you make it so that when you have 0 bullets it will play a reloading animation with this script advance thxn
@misc-i6q3 жыл бұрын
I tried but it was crazy buggy, if I get it to work I'll reply
@Hyphen33723 жыл бұрын
ok D4ngerous, very cool.
@whomp38172 жыл бұрын
idk how important this is to you anymore, but you'll need to set up an animator and create a trigger. For example: Reload. Then in your script, you add: "public Animator anim;" Then you put inside the reload function: "anim.SetTrigger("Reload"); Then you have to make transitions using the animator and your idle, reload, and shoot animation, which is a whole other hassle. I recommend watching Brackeys gun tutorial video, because he covers the creation of animations and how to use the animator in that. Good luck!
@vfwarlordforever95892 жыл бұрын
I'm curious, why do I set the bullet's rigid body to "interpolate"? The gravity part I get.
@user-qv5uy1ce7x Жыл бұрын
but if i shoot to many bullets it isnt gonna bug my game since the bullets dont get destroyed?
@peerfekt89033 жыл бұрын
for some reason its not working. I downloaded both of the scipts, after my own didnt work, but it still dont. i dont knoow why
@maarc_2 жыл бұрын
THANKS, but what if your Player doesnt have a rigid body?
@halivudestevez2 Жыл бұрын
very professional!
@soksopanha73483 жыл бұрын
Can someone tell me how to destroy your bullet when it collide. I really need help with that
@ion123v3 жыл бұрын
Yeah i need that too
@ion123v3 жыл бұрын
Create a script and add it to the bullet and then create the void that is responsable with collides and then an if statement that if it collides with the given tag then write in the curly brackets Destroy(gameObject);
@Tiltolet89173 жыл бұрын
So, I have a problem with this. On high speed bullets keep bouncing of the player, what can I do to fix that?
@sparkestic12383 жыл бұрын
Same here.... Do you find any solution
@MrFyce3 жыл бұрын
#3 Please!
@big_poo77362 жыл бұрын
i may just be doing too weak of a force but how would i get it so that i can rocket jump
@foolishlue2 жыл бұрын
when the bullet explodes, it just keeps exploding long after the bullet is destroyed and i dont know whats wrong
@GibsonYouTube4 жыл бұрын
hey, I've been having a pretty strange bug. whenever I walk forward while shooting, I get propelled forward really quickly. my guess is that it had something to do with the Bullet's Sphere Collider, and I was right. I turned off the Collider, and it was all fine. but, if I have my collider off, and it can't collide with anything (so enemies, the ground, etc...). I'm kinda lost on what to do. I tried having the script turn the collider off and on whenever the player was touching it, I messed with the physics engine, I've done everything that I can think of. if you or anyone has got any ideas on how to fix this that would be amazing! Keep up the good work man.
@davegamedevelopment4 жыл бұрын
Uff... I had the same issue, even tried the same stuff as you first :D The solution is to make a "whatIsBullet" and "whatIsPlayer" Layermask (and of course assign them to player and bullets :D). Afterward, you can open the "Physics" settings of your project, scroll down to the Layer Collision Matrix and uncheck the box where "whatIsBullet" and "whatIsPlayer" cross. This way bullets won't collide with the player at all :D Hope that helps!
@GibsonYouTube4 жыл бұрын
Dave / GameDevelopment I actually did that, but I fixed the problem. The problem was that I only set the player object to the WhatIsPlayer tag, and not any of the children. Which means that the bullet was probably colliding on the Gun itself lol. Thanks for help!
@gaminganimator-qp2ir4 жыл бұрын
@@davegamedevelopment i have 2 problems 1 i fly 2 how to make that enemys die
@gaminganimator-qp2ir4 жыл бұрын
@@davegamedevelopment ima use the ray cast gun but how to add sounds plz tell
@davegamedevelopment4 жыл бұрын
@@gaminganimator-qp2ir Here a tutorial on how to add sound: kzbin.info/www/bejne/bIC3ZWamq7qsnLs&ab_channel=Brackeys And are you using my movement script? :D
@misc-i6q3 жыл бұрын
Can you make a tutorial on how to make a sword? I want to add a katana that I made to my game but don't know how.
@priyadaksheshpatel83844 жыл бұрын
Hey my bullets don’t explode when they touch something plz help
@davegamedevelopment4 жыл бұрын
Check if the collision counter is really working and if the maxCollisions are set to something like 1-3 :D
@gaminganimator-qp2ir4 жыл бұрын
@@davegamedevelopmentcoz of the bullets the gravity seems to be very weak but if i delete script all works fine can somone help me out i did turn of the between players an bullets
@joeass23994 жыл бұрын
@@gaminganimator-qp2ir learn English or some language before learning a programming language
@gaminganimator-qp2ir4 жыл бұрын
@@joeass2399 dont you worry i know english i wrote that down when it was midnight i mean i was very sleepy
@joeass23994 жыл бұрын
gaming animator 1357 o ok sorry
@priyadaksheshpatel83844 жыл бұрын
Can you make the bullets stick to things plz
@davegamedevelopment4 жыл бұрын
Already did that, if you download the project file over my discord you'll find an order full of premade projectiles (splitting, sticking, spawning, teleporting etc.) :D
@XCalibur_EX3 жыл бұрын
So there seems to be a problem with how the spread is set up, if you aim off into a space with no objects the spread is 0, and if you are extremely close to an object the spread is ridiculously high
@thelegendarymushroom80 Жыл бұрын
same here, did you find a solution?
@kolczuritto51948 ай бұрын
yo, how to make the bullets disappear on impact?
@mrzack42992 жыл бұрын
Why are the links Bitly?
@davegamedevelopment2 жыл бұрын
To shorten them
@BLACKEDSNEPER2 жыл бұрын
@@davegamedevelopment but they are broken + when i fixed it i couldn't download it. can you paste the code or give me a different link(not in media file)
@KingRingsting4 жыл бұрын
hey, can anyone help me with my bullets, the damage is not consistent at all as my enemies have 100 health and i set bullet damage to 30 and sometimes it kills in 1 shot sometimes it kills in like 5, any help?
@zypherone2 жыл бұрын
Did you ever find a fox for this? I know why it’s happening but I’m looking for a fix
@KingRingsting2 жыл бұрын
@@zypherone i think i fixed it ages ago but i deleted the project sorry :(
@zypherone2 жыл бұрын
@@KingRingsting nah it’s ok I fixed it and I’m passed all that. Appreciate it bro
@KingRingsting2 жыл бұрын
@@zypherone good job on fixing it stuff like this can be so annoying
@zypherone2 жыл бұрын
@@KingRingsting I know right? This is my first game that I’m actually making progress on though. In case your curious I’m making a cod zombies inspired shooter with robots instead of zambies and parcore and upgradable weapons
@ethancantcode2 жыл бұрын
hwo do I make the bullets despawn when they hit the target
@davegamedevelopment2 жыл бұрын
Give them a new script, and inside of the void OnCollisionEnter function, just use Destroy(gameObject)
@ethancantcode2 жыл бұрын
@@davegamedevelopment Wow thanks its amazing that you actually answered since this video been out for more than a year
@RealJares2 жыл бұрын
please help me my bullets are invisible i have hid them an then undid it but even now when i shoot i can't see them i followed the other tutorial, everything was working fine but i just couldn't see the bullets man, please help me out with this
@LBLBLBLBLBLBLBLBLBLB3 жыл бұрын
I'm experiencing a bug where the Explode method will instantiate 3-5 explosions at a time, making the damage dealt somewhat random. I notice it goes away if I comment out the Invoke function. It seems to be going through the function multiple times until that 0.05 second delay is over, but I'm not sure why. I have some other scripts running, so that may be the issue, but I'm curious if anyone else had the same issue.
@ethanalkout9493 жыл бұрын
my explosion effect never stops playing actually
@mavelan3 жыл бұрын
happened to me too
@lukashere78033 жыл бұрын
Did u find a fix?
@bobj12342 жыл бұрын
same here. did u find a fix?
@dwkz1581 Жыл бұрын
I just had this issue too but i fixed it, i know i'm 2 years too late but all you need to do is decrease the delay, the bug seems to happen when the projectile uses up its collision limit, then it collides multiple times during that delay period, reducing the delay period drastically makes it only explode once.
@CuitoFlo6 ай бұрын
i have a problem, you know the bullets destroy themselves after the amount of max lifetime you put right, so since they all destroy themselves the gameobject of the bullet goes missing and projectile gun breaks cause theres no reference left
@CuitoFlo6 ай бұрын
nvm i fixed it ty for the tutorial very helpfull
@PolyPixelFusion2 жыл бұрын
How can we make the guns have sounds when firing?
@tinylarkl1421 Жыл бұрын
Use an audio source
@legoalternator2.0142 жыл бұрын
ok so im making a game but i have a problem im triing to make a mountabale turet like you se in fairs tose canons but idk houe to make a turet cod you do a video were you make a canon in ferst person tat wen you pres somting you become the canon and control it also the ammo must bounce
@legoalternator2.0142 жыл бұрын
and teres no video on houe to make sutch a ting
@Simon-Alexis2 жыл бұрын
Very late but if I use a character controller and not a rb how can I add a recoil? Nice video btw super useful!
@davegamedevelopment2 жыл бұрын
With a cc, I'm guessing you calculate a Vector3 for you velocity and then apply it with cc.Move(). In that case you would need to add a Vector3 that points backwards from your player to this velocity variable after you shooot, and then subtract it after some time to stop the recoil again.
@Simon-Alexis2 жыл бұрын
@@davegamedevelopment Makes a lot of sense, I’ll try that thx a lot
@nat221573 жыл бұрын
When i get too close to an object with a shotgun, or a high spread weapon, the bullets fly everywhere and nowhere near the target, is there a way to fix this?
@magma52673 жыл бұрын
did u find a fix?
@nat221573 жыл бұрын
@@magma5267 kinda, instead of using a hit point, i made the range a float and then it works for the most part. And a bool to choose between using a raycast and a float
@zeckl16642 жыл бұрын
How can we add sounds to this script pls help
@ethanalkout9493 жыл бұрын
i need help asap, the explosion particle never stops playing after bullet destroyed.. thanks in advance
@dwiNExx3 жыл бұрын
Un check the loop checkbox in the particle
@001Camera3 жыл бұрын
Same
@001Camera3 жыл бұрын
@@dwiNExx it still wont work
@elheffe76582 жыл бұрын
Hi! Even though my projectile has its sphere collider box checked in the inspector, its clones spawn in with their sphere collider box unchecked when I shoot. Anyone know why that might be or how to fix it?
@davegamedevelopment2 жыл бұрын
Did you apply all changes to the prefab?
@elheffe76582 жыл бұрын
@@davegamedevelopment Yeah that's what fixed it! I realized later that I forgot to change the original prefab. Sorry, I forgot to check back for a reply until now lol. Thanks!!
@bigglasses26257 ай бұрын
I can't assign a rigid body, because none exist in the list
@sourdoughbread952 Жыл бұрын
the explosion just keeps playing! Why?? i did exactly what you did
@chakibchemso3 жыл бұрын
you're awesome!
@rayhan2852 жыл бұрын
For those who have problem with the damage Try typing If (enemies[i].GetComponent()) enemies[i].GetComponent().TakeDamage(damage); Also, you need the target script from shooting with raycast from brackeys
@stephenmurya2 жыл бұрын
I've spent close to a month cracking my brain on how to do this. Thank you!
@Maskeowl Жыл бұрын
i wana use his code for 2d in 3d space so i have bullet sprite and bullets arent cirqular so i need to rotate tthem allong with aim how i can do that ?
@bloc1464 жыл бұрын
Awesome!
@Spastic1103 жыл бұрын
How can I add recoil where the gun goes back when you shoot
@ElvishGaming14 жыл бұрын
please update this script by adding shooting sound FX
@Dogmut4 жыл бұрын
hey! quick question, when i shoot and the bullet explodes, the bullet keeps exploding and doesn't go away? any solution? starts to get very messy after shotting a lot of bullets
@gurdog77313 жыл бұрын
Same Here :(
@Dogmut3 жыл бұрын
@@gurdog7731 if I can remember how I got around to solving the issue, There's a dropdown on the particle system that defines the behaviour when the particles end (can't remember what it's called), you can change to destroy, me and my mate did this I believe, let me know if this helps ! :)
@gurdog77313 жыл бұрын
@@Dogmut thanks
@ps5games8214 жыл бұрын
Please make more tutorials
@davegamedevelopment4 жыл бұрын
Yes I will :D But also Devlogs of games I make :D
@gaminganimator-qp2ir4 жыл бұрын
@@davegamedevelopment if ur so good at programming why not make ur game
@derangeddoffy2 жыл бұрын
I'm getting an error: MissingReferenceException: The object of type 'GameObject' 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. My muzzleflasheffect also keeps getting cloned in the hierarchy.
@pebble75002 жыл бұрын
I have 5he same problem if you found out why pls tell me
@pebble75002 жыл бұрын
The
@derangeddoffy2 жыл бұрын
@@pebble7500 I never found out and I quit Unity
@whysl2 жыл бұрын
@@pebble7500 It's because, you drag your bullet from Hierarchy to script, you need to drag your bullet into asset, and from asset to the script Sorry for my English
@pebble75002 жыл бұрын
@@whysl Thanks a lot! Even tho I moved on to roblox studio now, maybe in the future I will come back to unity and use it. So thanks alot!
@LeHalazoone3 жыл бұрын
Please, can you help me? In my fps game, the player does not shot in the center of the screen in the crosshair. Can you help please?
@LeHalazoone3 жыл бұрын
@Engloosh i took off the pistol animation white shooting, and i spent some time maninulating the rotation of the gun untill the bullet was into the crosshair. Try that and good luck.
@LeHalazoone3 жыл бұрын
@Engloosh do you have the script ? Thanks
@self_destruction76033 жыл бұрын
I copyd it and thx a lot
@AZASeraph3 жыл бұрын
Why does the recoil move the player and not the gun
@zillionjarl80032 жыл бұрын
Ik I’m very late but the bullets don’t damage objects just bounces them
@firetiredesire Жыл бұрын
the spread changes to 0 when i turn 90 percent why is this
@gamerdev10563 жыл бұрын
my grenades keep getting destroyed and then I can't use them again :(
@BigWoofer4 жыл бұрын
I've got a couple questions to ask (srry for commenting so much at this point) #1 everytime I fire, the gun uses up 2 bullets rather than 1 even though my bullets per tap is 1 #2 What could cause my spread not to work? I have all the calculation lines in and the bit that adds the calculations to the Vector3 #3 Even though I have a rigidBody on the player, and it's linked to the gun, what could cause it not to recoil properly
@BigWoofer4 жыл бұрын
Figured out 1 right after I commented, sorry about that
@davegamedevelopment4 жыл бұрын
@@BigWoofer Maybe download the project file and see how everything is set up there :D (over my discord)
@BigWoofer4 жыл бұрын
@@davegamedevelopment I did, it didnt help unfortunately, I'm sure I'm missing something obvious I'm just not sure what it could be, I ended up switching over to a hit scan weapon temporarily and managed to get spread working on that, still having issues with the recoil though
@gaminganimator-qp2ir4 жыл бұрын
@@BigWoofer just copy the cody (or not coz ur not gona learn anything then)
@tamamlanmamis4 жыл бұрын
I have a problem. it doesn't show me the muzzle flash effect when I enter play mode edit: explosion effect doesn't work too edit: ok I found out what was wrong
@lafrek81454 жыл бұрын
What was wrong??
@atsurao4 жыл бұрын
tell me how u fixed it plz im having the same problem
@AnonymouseNO.1Ай бұрын
shooting is broken after attaching bullet script on bullet - speed is weird and soo fast
@emil90804 жыл бұрын
Solved Could someone help me Assets\CustomBullet.cs(66,18): error CS0029: Cannot implicitly convert type 'void' to 'bool' the script is (enemies[i].GetComponent().TakeDamage(explosionDamage));
@2koolbros1543 жыл бұрын
U put two Brackets in the end
@everythingbyisaac3 жыл бұрын
hi can you make a video on how to kill a enemy on imacet
@CryosBS2 жыл бұрын
in enemyAI script: private void OnCollisionEnter(Collision collision) { if (collision.collider.gameObject.CompareTag("Bullet")) TakeDamage(120); } in the inspector create a tag named Bullet and add it to your bullet (set damage to enemy health)
@everythingbyisaac2 жыл бұрын
@@CryosBS thanks
@gaminganimator-qp2ir4 жыл бұрын
ok plz do health and damage system tut plz the only thing i need
@sanjayrajasree7914 жыл бұрын
Me too
@iceysnowdragon9163 Жыл бұрын
This script here is not being activated for some reason for (int i = 0; i < enemies.Length; i++) { //Get component of enemy and call Take Damage enemies[i].GetComponent().TakeDamage(explosionDamage); Debug.Log("colliding"); //Add explosion force (if enemy has a rigidbody) if (enemies[i].GetComponent()) enemies[i].GetComponent().AddExplosionForce(explosionForce, transform.position, explosionRange); } So my enemy isn't taking any damage. Is there any problem with this code? Edit: The reason why this wasn't working was because the collider that was set on my enemy was through the floor instead of on the enemy.
@retlyfast4816 Жыл бұрын
For people having trouble with shot bullet and it explode but the explosion did not stop i found some solution 1 uncheck loop (if you are using unity particle pack dont forget to uncheck child too) 2 Under particle system there is stop action button change to destory hope it will useful sorry for my english grammer
@alinatelyk2 жыл бұрын
Your voice sounds extremely familiar 🤔
@davegamedevelopment2 жыл бұрын
Haha I know
@L0rdBud4 жыл бұрын
I'm making a shot gun, so it shoot 8 bullets per tap, but they all instantiate at the exact same point and instantly destroy each other(my bullets have a script where they are destroyed when the collide with something)
@zypherone2 жыл бұрын
My guess is to add a line to the script that offsets the bullets based on its spread value
@catman74742 жыл бұрын
did you fix it I have the same problem
@L0rdBud2 жыл бұрын
@@catman7474 i dont remember tbh
@wanbungus2 жыл бұрын
i imported the unity particle explosion pack and now my entire project is gone bruh
@whomp38172 жыл бұрын
if you're still interested in this issue, you have to import the settings required, and then if you are using a Unity 3D URP, then you have to go to your package manager and remove PostProcessing
@renatogenovese27184 жыл бұрын
hey dave i'm working on a 2d top down shooter and i'm using your script from the first projectile gun tutorial without reloading,the bulletsleft and the ray. when i do a burst gun instead of firing like RATATA, RATATA, it fires like RATATATA, RA, RATATATA, RA, maybe because it invokes resetshooting also with the burst projectiles. i'm also always shoting when i use the right analog because it moves with the left joystick and rotates with the right joystick. here is my code. can you help me?? using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class player : MonoBehaviour { //general Rigidbody2D rb; //movement public float movespeed; Vector2 movement; public FixedJoystick movejoystick; //rotation public float rotatespeed; public Joystick rotatejoystick; //shooting public GameObject bullet; GameObject bulletshotted; public Transform head; public float bulletspeed; public bool readytoshoot; public float timebeetweenshooting; public guncontainer gun; public int bulletspertap; public int bulletsshot; public float timebtwnshots; public bool allowinvoke; void Update() { //movement float horizontal = movejoystick.Horizontal; float vertical = movejoystick.Vertical; movement.x = horizontal; movement.y = vertical; //rotation Vector3 movevector = (Vector3.up * rotatejoystick.Horizontal + Vector3.left * rotatejoystick.Vertical); if (rotatejoystick.Horizontal != 0 | rotatejoystick.Vertical != 0) { transform.rotation = Quaternion.LookRotation(Vector3.forward, movevector); } //shooting if (rotatejoystick.Horizontal != 0 && readytoshoot || rotatejoystick.Vertical != 0 && readytoshoot) { Shoot(); bulletsshot = 0; } timebeetweenshooting = gun.timebetweenshooting; bulletspertap = gun.bulletspertap; timebtwnshots = gun.timebtwnshots; } void FixedUpdate() { rb.MovePosition(rb.position + movement * movespeed * Time.deltaTime); } public void Shoot() { if (bulletsshot < bulletspertap) Invoke(nameof(Shoot), timebtwnshots); readytoshoot = false; bulletshotted = Instantiate(bullet, head.position, head.rotation); Rigidbody2D bulletrb = bulletshotted.GetComponent(); bulletrb.AddForce(head.up * bulletspeed * Time.deltaTime, ForceMode2D.Impulse); Destroy(bulletshotted, 2); bulletsshot++; if (allowinvoke) { Invoke(nameof(Resetshooting), timebeetweenshooting); allowinvoke = false; } } void Awake() { rb = GetComponent(); readytoshoot = true; bulletsshot = 0; allowinvoke = true; } private void Resetshooting() { readytoshoot = true; allowinvoke = true; } }
@pressstartperlerbeads3132 жыл бұрын
The tutorial is great but I can't get my gun to actually damage and destroy objects, can anyone help?
@aaroncrepeele57002 жыл бұрын
help i cant download the script the url did not work can you pleace paste the script in the commends?!