Shooting with Raycasts - Unity Tutorial

  Рет қаралды 1,892,765

Brackeys

Brackeys

7 жыл бұрын

Let's create a shooting gun with muzzle flash, impact effect and force.
● Sci-Fi Weapons: devassets.com/assets/sci-fi-we...
● Medieval Arena: devassets.com/assets/medieval-...
● Western Props: devassets.com/assets/western-p...
❤️ Donate: www.paypal.com/donate/?hosted...
····················································································
► Join Discord: / discord
♥ Subscribe: bit.ly/1kMekJV
● Website: brackeys.com/
● Facebook: / brackeys
● Twitter: / brackeystweet
········································­­·······································­·­····
Edited by the lovely Sofibab.
········································­­·······································­·­····
► All content by Brackeys is 100% free. I believe that education should be available for everyone. Any support is truly appreciated so I can keep on making the content free of charge.
········································­­·······································­·­····
♪ Baby Plays Electro Games
teknoaxe.com/cgi-bin/link_code...

Пікірлер: 3 600
@Brackeys
@Brackeys 7 жыл бұрын
I hope you will enjoy the videos guys! I will have a tutorial on Weapon Switching coming up this sunday. Oh and sorry about the over exposed footage ;) I hope some of you will participate in Ludum Dare this weekend - I sure will and plan to make a video about it as always :D Good luck and remember to have fun!
@GameS-lu2vz
@GameS-lu2vz 7 жыл бұрын
Im looking forward to it
@RitobanRoyChowdhury
@RitobanRoyChowdhury 7 жыл бұрын
Can you do some more advanced tutorials for Unity. I would love to see some prototype versions of mainstream games (e.g. Hearthstone, not No Man's Sky, etc.).
@jamesrandomname1000
@jamesrandomname1000 7 жыл бұрын
I can't set up the arenas materials and textures ;(
@jamesrandomname1000
@jamesrandomname1000 7 жыл бұрын
the arena doesnt come up when i drag it in
@jamesrandomname1000
@jamesrandomname1000 7 жыл бұрын
i also just fall throught the arena
@stormillion5002
@stormillion5002 4 жыл бұрын
"Void die" is a powerful expression
@baby3ddie286
@baby3ddie286 4 жыл бұрын
*void
@betoj.l.2817
@betoj.l.2817 4 жыл бұрын
Poor Void
@Simon-tb6tn
@Simon-tb6tn 4 жыл бұрын
I'm going to void to get back to base
@sonic26flash52
@sonic26flash52 3 жыл бұрын
void*
@voidnn3183
@voidnn3183 3 жыл бұрын
:(
@djninjitsuchannel7857
@djninjitsuchannel7857 5 жыл бұрын
"so now when we go back to unity we shouldn't see any error" My console: 1037 errors
@DavidB-rx3km
@DavidB-rx3km 4 жыл бұрын
The problems always come from not following the tutorial from start to finish - you will always miss one variable somewhere. :) I was putting this into my own script and missed the damage and range variables, and then spent 5 minutes going back through the video for it. :(
@_CloudyBunny
@_CloudyBunny 4 жыл бұрын
That's the daily life of developers. : )
@lonttugamer2939
@lonttugamer2939 4 жыл бұрын
@@DavidB-rx3km or following outdated tutorials, but i don't think that's the case.
@meganm4350
@meganm4350 4 жыл бұрын
lolololololololol
@kenan2386
@kenan2386 4 жыл бұрын
oh
@extremegameplays7404
@extremegameplays7404 3 жыл бұрын
everybody gangsta till the cyllinder gets a gun
@testosteroneoverdose
@testosteroneoverdose 3 жыл бұрын
no *B E A N* capsule
@lah3544
@lah3544 3 жыл бұрын
@Jakey K *karlson vibe plays in the background*
@talrushkeviz5582
@talrushkeviz5582 3 жыл бұрын
no, B E A N would get a gun
@testosteroneoverdose
@testosteroneoverdose 3 жыл бұрын
dun din dan dundundundun dun din dao ding dundundundun
@testosteroneoverdose
@testosteroneoverdose 3 жыл бұрын
Do you mean the AT-48
@fingerflowerstudios
@fingerflowerstudios 3 жыл бұрын
Me: wants me I start a game studio with my cousin Brackeys: I’m about to start this mans whole career
@pikachu-jf2oh
@pikachu-jf2oh 3 жыл бұрын
LOL
@monarc8347
@monarc8347 3 жыл бұрын
@@pikachu-jf2oh bruh
@blk9365
@blk9365 3 жыл бұрын
@@pikachu-jf2oh read better
@camtuber23
@camtuber23 3 жыл бұрын
@@pikachu-jf2oh He said I’m about to *start* this mans whole career. Not, I’m about to *ruin* this mans whole career.
@jaywalker70731
@jaywalker70731 3 жыл бұрын
same here man... but with brother
@Mousesenpai
@Mousesenpai 5 жыл бұрын
he almost covered all the main aspect of FPS games in just 13 mins without any delay. amazing 10/10. This video is so much detailed .
@BlazertronGames
@BlazertronGames 5 жыл бұрын
Well he used a premade FPS script.
@mrpotat680
@mrpotat680 4 жыл бұрын
@@BlazertronGames He used his premade fps pack.
@mathstarz1168
@mathstarz1168 4 жыл бұрын
He even discussed the nature of life's meaning as well! Did you catch it?
@toast5850
@toast5850 4 жыл бұрын
Engrish?
@KiloLime
@KiloLime 4 жыл бұрын
Bruh your gun shoots high... does anyone have a answer to this??? I know i did it correct but its not shooting on the cross hair
@TinyDeskEngineer
@TinyDeskEngineer 3 жыл бұрын
Ah, a medieval arena, a wooden crate, and someone with a FUTURISTIC LASER BLASTER
@Tezos1644
@Tezos1644 3 жыл бұрын
lol
@pizzapie5226
@pizzapie5226 3 жыл бұрын
lol
@_veselin_5048
@_veselin_5048 3 жыл бұрын
Realistik 100
@TinyDeskEngineer
@TinyDeskEngineer 3 жыл бұрын
@Sourav Parik oh yeah, time travel makes sense.
@cinemacat4108
@cinemacat4108 3 жыл бұрын
I think we should appreciate that he is teaching us with some cool assets that are for free , it is a good joke tho
@levibotos2534
@levibotos2534 3 жыл бұрын
Me: its correct Visual Studio: its correct Unity: you cant enter play mode with compiler errors.
@cosmonut-fr
@cosmonut-fr 3 жыл бұрын
You need to attach VS code with Unity
@cosmonut-fr
@cosmonut-fr 3 жыл бұрын
Then it will start calculating all your errors,tnx
@techjunkyben
@techjunkyben 3 жыл бұрын
sooooooooooooooooooooooooooooooooooooooooooooooooo true XD
@dynacycle
@dynacycle 3 жыл бұрын
2020 unity is the worst unity, it will ever be
@cosmonut-fr
@cosmonut-fr 3 жыл бұрын
@@dynacycle never be whay
@redtshirtgaming4418
@redtshirtgaming4418 3 жыл бұрын
Brackeyes: void die void: pls no
@jimmyfigliomeni9385
@jimmyfigliomeni9385 4 жыл бұрын
Brackeys team, I just want to say thank you for putting together all of these tutorials. They are laid out and presented well, allowing for even a novice like me to follow! Well done and I look forward to watching more in the future!
@ignskeletons
@ignskeletons 4 жыл бұрын
I feel like I'm getting a full college level education from your KZfaq channel but without any of the student debt. Thank you sir for the amazing content you provide for Unity!
@bestofgaming3495
@bestofgaming3495 3 жыл бұрын
Me
@charliedeschambault2599
@charliedeschambault2599 3 жыл бұрын
Heyyy plz help
@ahmedmohamed-cd7xf
@ahmedmohamed-cd7xf 3 жыл бұрын
Anybody having the same problem of" 'Target'Does not contain a definitionfor'TakeDamage' and no accessible extension method'TakeDamage'accepting a first argument of type 'Target' could be found" please heelp🥲
@lr514
@lr514 3 жыл бұрын
I know I’m 1 month late, but it means you either forgot to make the method TakeDamage entirely or you forgot to make it public
@cucksterhingle5930
@cucksterhingle5930 3 жыл бұрын
@@ahmedmohamed-cd7xf save all of your .cs files, if you dont save all of them target doesnt become public
@michaelrothkopf4088
@michaelrothkopf4088 4 жыл бұрын
YOU ARE THE BEST I LOVE YOUR CHANNEL THANK YOU! I would have never gotten into Unity dev without you. You have been so helpful. You turned something so complicated and made it super simple. Instead of making it look easy, you make it easy. THANK YOU.
@MuditGupta89
@MuditGupta89 6 жыл бұрын
I like how he manages to keep the content easy for newbies to understand while moving at a breakneck speed and not wasting one second of the viewers' time. That's talent right there.
@HOTA200
@HOTA200 7 жыл бұрын
this is the best channel for unity users
@hideyboishit
@hideyboishit 5 жыл бұрын
agrreedddd
@ferdizhivina6362
@ferdizhivina6362 5 жыл бұрын
don't forget Jimmy Vegas , he has a good channel too
@humphred4912
@humphred4912 5 жыл бұрын
he is an incredibly good teacher.
@mason3872
@mason3872 5 жыл бұрын
*CODING YOUR OWN GAMES IS EASIER THAN YOU THINK*
@lilpup1414
@lilpup1414 4 жыл бұрын
I would like but its at 420
@corr2143
@corr2143 3 жыл бұрын
That was an awesome description of the raycast hit, was able to implement the same thing to a character kicking objects, learned the transform.name and the rayccast in one video and many more things, you're awesome Brackeys!
@aperm8834
@aperm8834 3 жыл бұрын
since I saw everyone had +1000 errors here you have boys enjoy: -Gun.cs: using System; using System.Diagnostics; using UnityEngine; public class Gun : MonoBehaviour{ public float damage = 10f; public float range = 100f; public float fireRate = 15f; public float impactForce = 30f; public Camera fpscamera; public ParticleSystem muzzleflash; public GameObject impactEffect; private float nextTimeToFire = 0f; // Update is called once per frame void Update () { if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire) { nextTimeToFire = Time.time + 1f / fireRate; Shoot(); } } void Shoot () { muzzleflash.Play(); RaycastHit hit; if (Physics.Raycast(fpscamera.transform.position, fpscamera.transform.forward, out hit, range)) { UnityEngine.Debug.Log(hit.transform.name); Target target = hit.transform.GetComponent(); if (target != null) { target.TakeDamage(damage); } if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * impactForce); } GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impactGO, 2f); } } } ---------------------------diferent script-------------------------------- target.cs: using UnityEngine; public class Target : MonoBehaviour { // Start is called before the first frame update public float health = 50f; public void TakeDamage (float amount) { health -= amount; if (health
@drokos8239
@drokos8239 3 жыл бұрын
hi i tried it and it still doesnt work, it said: the type or namespace name Target could not be found (are you missing a using direcetive or an assembly reference) please help
@aperm8834
@aperm8834 3 жыл бұрын
@@drokos8239 Just to make sure these are the 2 scripts are you sure you didnt copy the part where I enter target.cs if you didn't could you give me the exact error
@cianj8798
@cianj8798 3 жыл бұрын
in Gun.cs " Target " is showing up as an error, saying it could not be found
@jordangonzalez4193
@jordangonzalez4193 3 жыл бұрын
@@cianj8798 you need to do the target.cs code for that code to work
@volcanowater
@volcanowater 3 жыл бұрын
there is a error called Assets\Target.cs(22,6): error CS1513: } expected
@Pr3DaToR15
@Pr3DaToR15 7 жыл бұрын
So quick. .yet very detailed. Learnt a few new things. Thanks.
@magnusm4
@magnusm4 7 жыл бұрын
Going by these alone, just some few things and you have the basic controls for an fps. Now just need levels, models, sound and ai
@Cyreides
@Cyreides 7 жыл бұрын
I watched this even though it's completely irrelevant to the needs of my own Unity project (I'm making a 3D platformer) because simply put... your tutorials are so interesting and thorough and insanely professional in presentation that I can't help but watch, and I still think I ended up learning somethings that I'm sure will be useful down the road. I'm gonna be digging through the rest of your videos as I can! Keep up the amazing work!
@d-o-n-u-t
@d-o-n-u-t 4 жыл бұрын
Procrastination via NOT procrastination. Stop it, Cyreides... you're scaring the kids...
@samgillespie68
@samgillespie68 4 жыл бұрын
The Diamond Gamer ?
@FaissalsAnimation
@FaissalsAnimation 3 жыл бұрын
It's sad that this channel is "gone"
@ArthurOliveira-zq1tw
@ArthurOliveira-zq1tw 3 жыл бұрын
Man.... it actually hurts
@bedo2950
@bedo2950 3 жыл бұрын
People ask me why you are depressed Me: No one will understand how sad i was when brackey left the youtube
@danielhuang6668
@danielhuang6668 3 жыл бұрын
We dont talk about that here
@astickman2486
@astickman2486 3 жыл бұрын
:(
@charliedeschambault2599
@charliedeschambault2599 3 жыл бұрын
Heyy plz help
@llucgarciacrumols4330
@llucgarciacrumols4330 9 ай бұрын
The best video I have found about how to use raycasts, very well explained, with clear information. Thanks for the video.
@yikes1910
@yikes1910 7 жыл бұрын
The quality of these videos are amazing, keep up the good work! 💪
@coolboidoesstuff9828
@coolboidoesstuff9828 5 жыл бұрын
literally. It is default 1080p HD
@Shutupnerd904
@Shutupnerd904 2 жыл бұрын
@@coolboidoesstuff9828 time to be wooshed away
@gmplus9842
@gmplus9842 2 жыл бұрын
@@coolboidoesstuff9828 so your telling me that FHD is normal dude im waching this vid in 480?
@hypercharge26
@hypercharge26 8 ай бұрын
@@coolboidoesstuff9828 r/whooooooooosh after 4 years get rekt
@CapitalOBeats
@CapitalOBeats 5 жыл бұрын
Loving the tutorials brotha, Only been game making for about a month. And your videos seem to be to only ones i watch, and dont end up with a headache and a bunch of errors lol. Keep it up
@SunaKhei93
@SunaKhei93 3 жыл бұрын
You know Brackeys, THIS helped me a shit ton right now. Thank you!
@CookingWithCows
@CookingWithCows 7 жыл бұрын
I really love your channel. It helped me a lot in programming in Unity, so thank you for what you do! I would like to see a video/mini series on how to make a simple inventory system with an inventory/bag UI, different item classes that do different things when left/right clicked while held in your hand and so on. Think minecraft/harvest moon. How to make sure your character doesn't try to drink your axe or shoot with your potion. How to "make" different item classes with different properties in an outside source like a json file (a potion doesn't need a fire rate, or does it, is fire rate the same as drinking cooldown, a crossbow doesn't need a property of how much it heals you) and how to import them into the game as an items list. common pitfalls and things where people get stuck when creating an inventory/item system.
@robloxiansexclusive1781
@robloxiansexclusive1781 2 жыл бұрын
woah
@realcolby
@realcolby 4 жыл бұрын
I love how easy these tutorials are for beginner and experienced programmers.
@NewHopeGames
@NewHopeGames 3 жыл бұрын
I been searching around for fps shooting tutorials. This video is really helpful.
@MMT--Games
@MMT--Games 4 жыл бұрын
Me: *Makes Everything Correctly.* Unity: *999+ Errors.*
@nerdly5759
@nerdly5759 4 жыл бұрын
You are 2 years late
@MMT--Games
@MMT--Games 4 жыл бұрын
@@nerdly5759 ah shit...
@nerdly5759
@nerdly5759 4 жыл бұрын
;-)
@Nuff.x
@Nuff.x 4 жыл бұрын
@@nerdly5759 so this doesn't work anymore??
@nerdly5759
@nerdly5759 4 жыл бұрын
It works
@ZalkinVr
@ZalkinVr 4 жыл бұрын
As someone that is working on a solo indie project, I found this video incredibly useful.
@krookked5868
@krookked5868 6 жыл бұрын
you are the special person that is making my dream job possible
@Underarmour81
@Underarmour81 3 жыл бұрын
Worked amazing for what I needed! Still one of the best, sad their no longer doing anymore content.
@crazykidplayz6498
@crazykidplayz6498 2 жыл бұрын
I spent 12 days trying to get guns working in my game and MY BOY BRACKEYS HAD A VIDEO ON IT THE WHOLE TIME
@thesenate6523
@thesenate6523 2 жыл бұрын
Brackey: just create a particle that you like My Brain: Error 404
@ionpotato1562
@ionpotato1562 2 жыл бұрын
i had to look up another tutorial
@nuffuru1490
@nuffuru1490 3 жыл бұрын
I would recommend adding the line "ImpactGO.transform.parent = hit.transform;" after instantiating your impacteffect because if you're working with bulletholes too this way the bulletholes will move with the object they're on instead of just staying there.
@jacobp.6160
@jacobp.6160 Жыл бұрын
needed this to use the effect for different types of effects. Thank you
@keith819
@keith819 3 жыл бұрын
By far teachers like yourself are what makes Unity shine
@null9117
@null9117 2 жыл бұрын
Thank you so much! Even after 4 years, this video still saved my life!!!!!!
@feeney8715
@feeney8715 2 жыл бұрын
I learned SO much from this one tutorial, - I learned raycasts - I learned more variables - I learned how to acces scripts from scripts (lol) - I learned how to make a crosshair and WAY more, ty for the tutorial!
@duracellbattery3625
@duracellbattery3625 4 жыл бұрын
Thank you for helping me make a game I had no clue on what to do and after watch like 5-6 videos I’m starting to get it just wanted to thank you for everything
@joblesskid5922
@joblesskid5922 2 жыл бұрын
i replayed this vid 6 times just to i can help funding , but they're arent any ads, means this tutorial is really earning nothing but it taught me a lot... i love you host
@urielcobo-cuisana2316
@urielcobo-cuisana2316 2 жыл бұрын
He- He left us 10 months ago. 😭
@joblesskid5922
@joblesskid5922 2 жыл бұрын
@@urielcobo-cuisana2316 i agree , we all miss him. he was the best teacher ive seen so far.. do you know someone else like him that makes similar content for "unreal engine" ? cause im really looking for one
@tylerstyle307
@tylerstyle307 4 жыл бұрын
this is the video I visit the most... Thanks Brakeys!
@SHAHSAMINYASAR
@SHAHSAMINYASAR 3 жыл бұрын
*_Me while watching this:_* Wow,,that's so easy. *_Me after coding:_* error;error;error;error
@monarc8347
@monarc8347 3 жыл бұрын
Yes the pain
@astickman2486
@astickman2486 3 жыл бұрын
@@monarc8347 Hello there
@monarc8347
@monarc8347 3 жыл бұрын
@@astickman2486 General Ken Obi
@pythro_
@pythro_ 3 жыл бұрын
@@monarc8347 Ahh, nice
@monarc8347
@monarc8347 3 жыл бұрын
@@pythro_ General Pytro
@ChatteringAnimalXd
@ChatteringAnimalXd 2 жыл бұрын
After watching and following the video I threw a salute so hard that I almost cracked my skull, thanks Brackeys. You are a legend.
@subarunatsuki1902
@subarunatsuki1902 2 жыл бұрын
A-are you okay?
@simonkerridge
@simonkerridge 4 жыл бұрын
Wow! Very useful tutorial. So much information in so short a duration. Well done!
@historvical6062
@historvical6062 3 жыл бұрын
The legend never dies...
@APMM19
@APMM19 3 жыл бұрын
Uh
@DeitelSoft
@DeitelSoft 7 жыл бұрын
Good! Thank you for the tutorials, greetings from Mexico!
@alwayssoftgames6636
@alwayssoftgames6636 Жыл бұрын
If anyone wants the raycast to shoot out of a specific point of the gun (like the muzzle) instead of out of the center of the screen, do this: -First, go into the fire script -change the "public Camera fpsCam" variable to a "public Transform muzzle" variable (you can name the Transform whatever you want, I chose "muzzle") -Then in the "Void Shoot" function change the "fpsCam.transform.position" to "muzzle.transform.position" and the "fpsCam.transform.forward" to "muzzle.transform.forward" -Now in the inspector drag and drop the muzzle of the gun into the "Muzzle" component. -If your gun does not have a muzzle, create an empty object that is the child of the weapon, name it "Muzzle", and position it on the tip of your gun. Hope this helps, it worked for me.
@jacobscott8277
@jacobscott8277 Жыл бұрын
Hey, I used your code, its not dectecting the ray when I click. This is my code (I change it slightly) using UnityEngine; public class gun : MonoBehaviour { public float damage = 10f; public float range = 100f; public Transform muzzle; // Update is called once per frame void Update() { if(Input.GetKeyDown(KeyCode.Mouse0)) { Shoot(); } } void Shoot () { RaycastHit hit; if (Physics.Raycast(muzzle.transform.position, muzzle.transform.forward, out hit, range )) { Debug.Log(hit.transform.name); } } }
@jacobscott8277
@jacobscott8277 Жыл бұрын
Nevermind sir I fixed it myself it was a issue with the rotation thank you for the info about the muzzle heres a free compliment... "your cool" - me
@IDKRipley
@IDKRipley 9 ай бұрын
Does this still work for now?
@berku
@berku 6 ай бұрын
you're@@jacobscott8277
@artursoares86
@artursoares86 3 жыл бұрын
The muzzle flash tip helped me a lot, thank you!
@doramus
@doramus Жыл бұрын
Really Useful Tutorial, We miss you Big Brack :(
@billythebuilder8724
@billythebuilder8724 3 жыл бұрын
Me: deletes start method, visual studio: 12467147628794 errors. Brackeys: deletes start method, visual studio: 0 errors or warnings. me: ok i dont get it
@pongraczadam828
@pongraczadam828 6 жыл бұрын
using UnityEngine; public class gun : MonoBehaviour { public float damage = 10f; public float range = 100f; public Camera fpsCam; // Update is called once per frame void Update () { if (Input,GetButtonDown("Fire")) { Shoot(); } } void Shoot () { RaycastHit hit; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) { Debug.Log(hit.transform.name); } } }
@optic_ozzygaming8993
@optic_ozzygaming8993 4 жыл бұрын
you sir are a god
@Simon-tb6tn
@Simon-tb6tn 4 жыл бұрын
Input.GetButtonDown and "Fire1" but thank you so much!!!
@carlosbaltazar5941
@carlosbaltazar5941 4 жыл бұрын
Isn't there more
@Simon-tb6tn
@Simon-tb6tn 4 жыл бұрын
@@carlosbaltazar5941 It's later in the video. This is the more boring stuff you don't have to really write to remember. It's intuitive.
@jaanoro1051
@jaanoro1051 4 жыл бұрын
You're a life saver
@Demonator131
@Demonator131 3 жыл бұрын
thanks brackeys! your the one who got me interested in making games!
@ManasJoshi
@ManasJoshi 3 жыл бұрын
Amazing Tutorial !! Love your videos. Keep them up. 10/10
@philiphutchings2477
@philiphutchings2477 4 жыл бұрын
If anybody is having trouble figuring out why their hit effect particles wont work(probably because you havent imported the effects system and just duplicated the muzzle flash and turned it into a hit effect basically), because you duplicated it, when you shoot it makes a new object right, so when its made its being awakened essentially, and because you duplicated the muzzle flash which had play on awake disabled, it wont display a hit effect. turn that bad boy on and you will have a hit effect when you shoot something. hope this helped anyone that struggled like i did
@GrayGhost28100
@GrayGhost28100 7 жыл бұрын
I know that this is for beginners, so maybe in another tutorial you should talk about how its better to pool objects that would other wise be created a lot so that its more efficient.
@Brackeys
@Brackeys 7 жыл бұрын
That's a really good idea! Noted :)
@invertexyz
@invertexyz 7 жыл бұрын
Also, to use RaycastNonAlloc so that you're not generating garbage every shot that the GC has to take care of.
@GoldenTab
@GoldenTab 7 жыл бұрын
Mr Anderson Noice idea! ;)
@cam4722
@cam4722 7 жыл бұрын
I would LOVE to see you do an object pooling tutorial so a newbie like me can understand it!
@hydraxdomin8009
@hydraxdomin8009 6 жыл бұрын
The function "Die" should be inside the class "TakeDamage".
@ClovisNeto
@ClovisNeto Жыл бұрын
Man! That's an amazing video, simple, quick and very objective! Loved it, thanks +1
@olivergeorge6202
@olivergeorge6202 2 жыл бұрын
Thank you so much for this tutorial! Really helped out a tone with my new game.
@suryanshjadhav9226
@suryanshjadhav9226 3 жыл бұрын
Brackeys: so now when we go back to unity we shouldn't see any error Unity: We don't do that here Even better: Brackeys: so now when we go back to unity we shouldn't see any error Unity: *HIPPITY HOPPITY ERRORS ARE NOW YOUR PROPERTY*
@dragonman7806
@dragonman7806 3 жыл бұрын
ikr
@xegrand7548
@xegrand7548 3 жыл бұрын
Is it me,or is your comment looking kinda T H I C C ?
@suryanshjadhav9226
@suryanshjadhav9226 3 жыл бұрын
@@xegrand7548 im a dani subscriber too!
@xegrand7548
@xegrand7548 3 жыл бұрын
@@suryanshjadhav9226 lol Karlson is off to become the most anticipated game of 2068
@suryanshjadhav9226
@suryanshjadhav9226 3 жыл бұрын
@@xegrand7548 so we wait 47 years... I thought 84 So when karlson releases when the entire fanbase i old ill tell my grandkids to buy it lol
@Dacommenta
@Dacommenta 6 жыл бұрын
Coding your own games is easier than you think.... u know.... you should take this online unity course on udemy...
@alexisbodet9195
@alexisbodet9195 6 жыл бұрын
this dude makes me crazy..!!
@kryptoniancuber6063
@kryptoniancuber6063 6 жыл бұрын
I always get that ad -_-
@brandonbennett9530
@brandonbennett9530 6 жыл бұрын
and as soon as i gave u a thumbs up, KZfaq suggested i go add free with a subscription!.... ahhh!
@willia_music
@willia_music 6 жыл бұрын
Funny enough I've been taking that Udemy course starting this year. And supplemented with Brackeys it has been a lot of help. Glad I got the course before seeing the adds or else I would have been like fuck that
@felixjanetzki7364
@felixjanetzki7364 6 жыл бұрын
This is so killing me
@giannisspernovasilis4266
@giannisspernovasilis4266 3 жыл бұрын
best tutorial channel ever
@kristiyanaleksiev8403
@kristiyanaleksiev8403 2 жыл бұрын
4 years later still using it. You are a beast.
@robertoleto2399
@robertoleto2399 2 жыл бұрын
I have a problem with the target variable, it doesn't exist
@kristiyanaleksiev8403
@kristiyanaleksiev8403 2 жыл бұрын
@@robertoleto2399 it worked for me
@akshat7310
@akshat7310 3 жыл бұрын
whose watching this after Brackeys quit?
@yaboiethan8112
@yaboiethan8112 3 жыл бұрын
OH OH ME!
@ahmadhashmi7791
@ahmadhashmi7791 3 жыл бұрын
yes me
@ahinssu617
@ahinssu617 3 жыл бұрын
yes :(
@fishy_96
@fishy_96 3 жыл бұрын
Yes me :( 😭
@sillyfella2009
@sillyfella2009 3 жыл бұрын
Me. :-(
@erykschubert
@erykschubert 3 жыл бұрын
If you use the impact effect, which creates the static mark on the object being hit and you don't want it to be destroyed, instead of using Destroy(impactGO, 2f), you can use ImpactGO.transform.parent = hit.transform to maintain the mark location on objects.
@ahmedmohamed-cd7xf
@ahmedmohamed-cd7xf 3 жыл бұрын
Anybody having the same problem of" 'Target'Does not contain a definitionfor'TakeDamage' and no accessible extension method'TakeDamage'accepting a first argument of type 'Target' could be found" please heelp🥲
@CAESAR_IS_GOD_mohammadisaloser
@CAESAR_IS_GOD_mohammadisaloser 2 жыл бұрын
how could I leave a bullet hole using that?
@ACBros_06
@ACBros_06 9 ай бұрын
6 years later still best tutorials
@aapdev
@aapdev 2 жыл бұрын
This video helped me implement fire rate in my FPS game, thanks brackeys! :D
@not_herobrine3752
@not_herobrine3752 3 жыл бұрын
Imagine being simply able to import the FPS character in later versions of unity
@ArthurOliveira-zq1tw
@ArthurOliveira-zq1tw 3 жыл бұрын
It would be NICE UNITY
@not_herobrine3752
@not_herobrine3752 3 жыл бұрын
Ok so i spent a week making my own, not the best substitute, but it will do
@teoskrn1518
@teoskrn1518 3 жыл бұрын
@@ArthurOliveira-zq1tw They don't now to try reducing the ammounts of assetflips made by incompetent people, I think.
@charliedeschambault2599
@charliedeschambault2599 3 жыл бұрын
Hey help me
@rohan_nishant
@rohan_nishant 3 жыл бұрын
@@not_herobrine3752 Brackeys has a tutorial for an fps character, you could have used that
@johnnyboyle5311
@johnnyboyle5311 2 жыл бұрын
Muzzle Flash Issue Solution: The solution that I found was turning the fire rate to 10 or below, for some reason when its higher the muzzle flash doesn't show up. (Also make sure to do this in Unity and not in the code as "fireRate" is a public variable). Hope this helps.
@timothyempey5028
@timothyempey5028 Жыл бұрын
Great tutorial, put together perfectly. Thanks
@Magic__Man
@Magic__Man 3 жыл бұрын
you are so cool! What you do for aspiring developers like me is amazing! Thank you kind person!
@rachelabella5044
@rachelabella5044 4 жыл бұрын
just a suggestion for the commenters: If you have a recoil animation it helps to use an animation event and make the particles go off of that
@michaelchurch2957
@michaelchurch2957 4 жыл бұрын
If anyone is having trouble with the muzzle flash not glowing like his. Go to the particle system, go to renderer , and in the material slot, change it from particle default (or whatever it is) to “Particle Glow”
@breadit2
@breadit2 11 ай бұрын
I added a light to mine, but it doesn't activate every time i shoot do you know why this might be
@aludra-star
@aludra-star 3 жыл бұрын
I very long time didn't know how I can do normal shooting but with your help I did it. Many thanks for your help.
@haydenjones8740
@haydenjones8740 4 жыл бұрын
This is the Best tutorial for this that I can find
@GameS-lu2vz
@GameS-lu2vz 7 жыл бұрын
Thanks, man! That film was really helpfull!
@tobycook9039
@tobycook9039 6 жыл бұрын
m8 this aint a film, its a youtube video XD
@Gredran
@Gredran 3 жыл бұрын
Anyone having issues with the muzzle flash: Follow Brackeys settings, but when I learned the BIG thing stopping me from succeeded, I realized I didn't have to, because it changes AS YOU PLAY. Follow exactly what he does, then parent gun model to camera(as in the start) then the particle system to the gun AND use it as the target as in 9:02. After this, it's not shooting right? Well with the particle system parented in this path(camera-gun-particle system) go to the system and now reset the transform(like you do when you add the ground check empty to to character). NOW try and it should work and any setting you change should be as you play!
@Anonymous-up6jt
@Anonymous-up6jt 2 жыл бұрын
Thanks A LOT
@anitakumar8276
@anitakumar8276 3 жыл бұрын
Dang! I just randomly saw this video and it helped me nice vid👍👍👍
@giteachvt
@giteachvt 4 жыл бұрын
I have a weeks experience and this helped me a lot!
@devaliero-3d597
@devaliero-3d597 5 жыл бұрын
Ну и строчит, как пулемет, и все по делу ! Не то что другие жуют сопли и тянут резину. Лайк! Brackeys, you are an an awesome lecturer!
@hierayku873
@hierayku873 5 жыл бұрын
СОгласен! All right!
@jakeschannel5461
@jakeschannel5461 5 жыл бұрын
Жаль, что я раньше не додумался искать уроки по Юнити у зарубежных ютюберов)
@camtuber23
@camtuber23 3 жыл бұрын
As as always, *the curly brackets.* :)
@NoobGameDev2
@NoobGameDev2 7 ай бұрын
Thank You So Much, I tried a few times and it didnt work but i finally got it working and am very happy with it and building off of it Thany You SOOOO SOOOO SOOOO MUC You do not understand how much this helped THANK YOU
@AverageSBREnjoyer
@AverageSBREnjoyer 2 жыл бұрын
ngl i love coming home and watching your vids! im thinking of making some games and using my own music too!
@axer1015
@axer1015 3 жыл бұрын
“And we’ll create a function... let’s call it die.” Me whenever I’m boutta smacc someone SO HARD into the sun.
@nuclearbomb9483
@nuclearbomb9483 2 жыл бұрын
Void Die() { rb.AddForce(0,1000 * Time.deltatime, 0); } Like this?
@boogiehasfun
@boogiehasfun Жыл бұрын
if you want to sprint here is some code you can add: in "void Update" add: if (Input.GetKey(KeyCode.LeftShift)) { speed = runSpeed; } else { speed = 6; } and add a public float called run speed with something similar to: public float runSpeed = 10f; and boom! you now have a simple running system in your game that can easily be changed.
@spaceballz1128
@spaceballz1128 2 жыл бұрын
Solving every error feels like a big brain moment.
@wargames43
@wargames43 3 жыл бұрын
Great tutorial used it to shoot a gun in VR made a barrel object for the gun where the "camera" is supposed to go since you can sway your hand around in VR
@lucafrancis5572
@lucafrancis5572 7 ай бұрын
If anyone is having the issue that I lost my mind over with the particles spawning randomly. Go to Auto Random Seed under the particle system and disable it. Then go over to the shape part and change it from a cone to a sphere and make the radius and radius thickness of the sphere something very small (like 0.0001). Hope this helps
@ICTitans
@ICTitans 7 жыл бұрын
Would you maybe do a segment on weapon recoil?
@FLXKZ
@FLXKZ 7 жыл бұрын
Weapon Recoil isn't really hard. I figured out myself. Here a little demonstration: First, you need a Recoil Vector: Vector3 Recoil; //private or public doesn't Matter And a max recoil amount: public float RecoilAmmount = 0.2f; //private or public doesn't Matter again, but I would make it public for ease of use Now before you cast your Ray we need to get a random Vector to change the direction the ray is firing. For that we can use Random.InsideUnitCircle which should give us a random point on a circle. Vector2 recoil = Random.InsideUniCircle()*RecoilAmount; When you now Fire your ray add the Recoil to the FPSCam.transform.forward so if (Physics.Raycast(FPSCam.transform.position, FPSCam.transform.forward + Recoil, out RayHit)) Hoped this helped you and other People. NOTE: I'm still a beginner. This should work, but I don't know if it is the most efficient way of doing it. I will make changes to this comment if someone has a better way.
@chinacat1337
@chinacat1337 7 жыл бұрын
Nice recoil script, I'm a beginner too but this gives a nice spread effect to a gun good work man
@XGamezOnlyX
@XGamezOnlyX 6 жыл бұрын
FYI, that script adds spread, not recoil.
@vaskedagame880
@vaskedagame880 6 жыл бұрын
-FLXKZ- Couldn't you put random between (-recoilammount , recoilammount) To get it on left as well? Am I mistaking?
@saltyscrimp
@saltyscrimp 4 жыл бұрын
@@FLXKZ Very useful my dude
@QueenElizabeth1sth
@QueenElizabeth1sth 2 жыл бұрын
Ah yes. Helping out even from the past. Thank you.
@federicostoppo1117
@federicostoppo1117 3 жыл бұрын
Incredible tutorial!!
@lovnishjain9287
@lovnishjain9287 4 жыл бұрын
By combining your tutorials i will make my own game soon. :)
@tssper3488
@tssper3488 4 жыл бұрын
Thats exactly what im doing now, except with my own terrible models and designs :)
@nitrozoronstudio2005
@nitrozoronstudio2005 4 жыл бұрын
everyone is LOL
@boba_t951
@boba_t951 4 жыл бұрын
@@tssper3488 Dude, you can use Google Poly for awesome models.
@angelconstandachi7905
@angelconstandachi7905 3 жыл бұрын
@@tssper3488 exactly da same
@logankrake2199
@logankrake2199 3 жыл бұрын
Same
@toluyole
@toluyole 3 жыл бұрын
Either I was watching this video with *X2* Speed or Brackeys was just going *SPEEDRUN!!!*
@cubecraftgaming9669
@cubecraftgaming9669 3 жыл бұрын
Well just watch it at 0.5x speed so he isn't going as fast as dream🤣🤣🤣🤣🤣
@ezzir7003
@ezzir7003 2 жыл бұрын
best youtuber in unity i hope you back to us one day
@skabben88
@skabben88 Жыл бұрын
I would recommend using hit.rigidbody.AddForceAtPosition(transform.forward * impactForce, hit.point); for adding force to the hit rigidbody. That takes into account where the normal was hit, which makes the object react more realistic to the impact.
@sushantdevkota1461
@sushantdevkota1461 3 жыл бұрын
This feels sad now
@FaissalsAnimation
@FaissalsAnimation 3 жыл бұрын
Yeah...
@yassineelatlassi6323
@yassineelatlassi6323 3 жыл бұрын
Aww :(
@ArthurOliveira-zq1tw
@ArthurOliveira-zq1tw 3 жыл бұрын
It really does
@Sp8dezz
@Sp8dezz 3 жыл бұрын
i swear im actually crying
@Sp8dezz
@Sp8dezz 3 жыл бұрын
it rlly hurts :(
@PabTSM-OfficialChannel
@PabTSM-OfficialChannel 3 жыл бұрын
Brackeys: Now we shouldn’t see any errors. unity: haha errors go BOOM BOOM
@ihumbleyou
@ihumbleyou 3 жыл бұрын
Same lol
@ahmedmohamed-cd7xf
@ahmedmohamed-cd7xf 3 жыл бұрын
Im having this error " 'Target'Does not contain a definitionfor'TakeDamage' and no accessible extension method'TakeDamage'accepting a first argument of type 'Target' could be found" please heelp🥲
@sparkestic1238
@sparkestic1238 3 жыл бұрын
@@ahmedmohamed-cd7xf i also have the same error
@sparkestic1238
@sparkestic1238 3 жыл бұрын
@@ahmedmohamed-cd7xf ok... I found one solution... Save your progress and than restart your project... It worked for me
@ahmedmohamed-cd7xf
@ahmedmohamed-cd7xf 3 жыл бұрын
@@sparkestic1238 wow it actually worked thank you so much❤❤
@mdtechnology7617
@mdtechnology7617 3 жыл бұрын
hi... i like your all videos and I have learnt so many things from you.
@divyanshuverma7128
@divyanshuverma7128 3 жыл бұрын
Thanks brackeys very very much!!
@m4TT5
@m4TT5 5 жыл бұрын
I wish he actually taught us how to make the muzzle flash cause I cannot figure out how he did it.
@gelis07
@gelis07 3 жыл бұрын
me too
@racegroundbreaking82
@racegroundbreaking82 3 жыл бұрын
@@gelis07 Yeah, I want that too. Maybe, he already made one? Can anybody tell me?
@gelis07
@gelis07 3 жыл бұрын
@@racegroundbreaking82 he made a video about unity's particle system
@racegroundbreaking82
@racegroundbreaking82 3 жыл бұрын
@@gelis07 thanks. edit: in case if someone wants to watch that: kzfaq.info/get/bejne/fKtxZNqFsrClgmQ.html
@mangaartistshamz8816
@mangaartistshamz8816 3 жыл бұрын
Watch Ups vid
@jorgeanimates4443
@jorgeanimates4443 3 жыл бұрын
for those who just want the code using UnityEngine; public class gunscript : MonoBehaviour { public float damage = 10f; public float range = 100f; public float fireRate = 15f; public Camera fpsCam; public ParticleSystem muzzleFlash; private object hit; public GameObject impactEffect; public float impactForce = 30f; private float nextTimeToFire = 0f; // Update is called once per frame void Update() { if (Input.GetButton("Fire1") && Time.time >= nextTimeToFire) { nextTimeToFire = Time.time + 1f / fireRate; shoot(); } } void shoot() { muzzleFlash.Play(); RaycastHit hit; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) { Debug.Log(hit.transform.name); target target = hit.transform.GetComponent(); if (target != null) { target.TakeDamage(damage); } if(hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * impactForce); } } GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal)); Destroy(impactGO, 2f); } }
@hshshshehd4
@hshshshehd4 3 жыл бұрын
thank you man i appreciate it
@kokachi3589
@kokachi3589 Жыл бұрын
thx
@Fagel536
@Fagel536 11 ай бұрын
it does not work
@jorgeanimates4443
@jorgeanimates4443 11 ай бұрын
@@Fagel536 idk man, that was the code in the video
@bo3o_8080
@bo3o_8080 11 ай бұрын
you are a time saver Thanks man W comment
@jarredhockley3332
@jarredhockley3332 4 жыл бұрын
You are such a legend, such a great way of explaining complicated topics in a simple yet in-depth manner. Truly thank you for your amazing help and Im gonna buy some assets soon :)
@nikrbawker
@nikrbawker 3 жыл бұрын
Finally got this working. All of the multiple target jumbo was causing some kind of detection or un-forseen typo with Unity2020.3. What I did was name my target Script to enemyTarget and also where it is referenced in the gun script. This made the lower cased target variable just work all of a sudden. For some reason using the default naming convention of this tutorial was making the TakeDamage go undetected. Awesome video a huge piece of gameplay that can be implemented in a ton ofgames.
@validuranium1890
@validuranium1890 3 жыл бұрын
I did that but then I get this: error CS0119: 'GameObject' is a type, which is not valid in the given context
@validuranium1890
@validuranium1890 3 жыл бұрын
nvm after three weeks, I realized I mad Game in gameObject capital when it shouldn't have been, bruh
@tobias231h
@tobias231h 7 жыл бұрын
A video about your Chrome Addons would be awesome!
How to get Good Graphics in Unity
8:14
Brackeys
Рет қаралды 1,2 МЛН
World’s Deadliest Obstacle Course!
28:25
MrBeast
Рет қаралды 54 МЛН
Stupid Barry Find Mellstroy in Escape From Prison Challenge
00:29
Garri Creative
Рет қаралды 11 МЛН
La revancha 😱
00:55
Juan De Dios Pantoja 2
Рет қаралды 49 МЛН
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 70 МЛН
FIRST PERSON MOVEMENT in Unity - FPS Controller
23:53
Brackeys
Рет қаралды 3,2 МЛН
Ammo & Reloading - Unity Tutorial
10:26
Brackeys
Рет қаралды 285 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 3,8 МЛН
Programming a Boss Battle For my Game
11:44
Dani
Рет қаралды 10 МЛН
Weapon Switching - Unity Tutorial
9:59
Brackeys
Рет қаралды 422 М.
I Made a Neural Network with just Redstone!
17:23
mattbatwings
Рет қаралды 558 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 402 М.
Unity FPS Movement Tutorial by Dani  |  Karlson Parkour FPS Controller
8:36
DanisTutorials
Рет қаралды 1,1 МЛН
He said I Couldn't Make a 3D Game... So I Made One!
10:29
Dani
Рет қаралды 9 МЛН
World’s Deadliest Obstacle Course!
28:25
MrBeast
Рет қаралды 54 МЛН