These small but useful tutorials are best to watch.
@talha95857 жыл бұрын
also, i would like to see switch animation
@coolboidoesstuff98285 жыл бұрын
@@talha9585 It is really not so hard, you can search up how to do it Edit: Never mind, it's harder than I thought
@dmudda905 жыл бұрын
@@coolboidoesstuff9828 no making games is much easier than you think! .. :D
@coolboidoesstuff98285 жыл бұрын
@@dmudda90 No I was talking about him asking for switching animation
@norriswu2135 жыл бұрын
@@dmudda90 "You should take this course on Udemy"
@zevac7 жыл бұрын
you're helping me create a universe, brackeys. i love you
@redbepis46005 жыл бұрын
Did you finish? Can I buy it?
@zeroiq47374 жыл бұрын
Red Bepis no lmao
@dexister69597 жыл бұрын
Your newest tutorials are so professional I can't imagine how long it takes to make a 2 minute video for you...
@chantendo29417 жыл бұрын
your tutorials are super helpful!
@Brackeys7 жыл бұрын
Thanks, glad you like it! :)
@neotomatoe72574 жыл бұрын
Yeah ;)
@Jamesthe17 жыл бұрын
You could also use modulo (aka the % operator) for the upward weapon switch. It would look like this: selectedWeapon++; selectedWeapon %= transform.childCount; If you don't know what modulo is, it basically gets the remainder from the division statement. You don't have to write a bunch of if statements that way. This saves a few lines and is actually quite efficient.
@light66027 жыл бұрын
Definitely should continue these smaller videos Brackeys!! Love them! I saw someone request an ammo system and I think that would be awesome! Along with a ui of course.
@SuperRalle1237 жыл бұрын
As always, these small tutorials are really great! I would love to see one about animations :)
@Cyreides7 жыл бұрын
I was going to need something similar like this for switching characters in my game, and this is perfect!
@bisharakhuri25045 жыл бұрын
Tutorial unclear.. Accidentally created CS:GO
@BredMan_4 жыл бұрын
lol
@sillyfella20094 жыл бұрын
I hate it when that happens
@KlutzOfAMan4 жыл бұрын
Task Failed Successfully
@ShyGus4 жыл бұрын
That's litterally how good these tutorials are😂😂
@Mikelica694 жыл бұрын
@@KlutzOfAMan XD
@deraidos457 жыл бұрын
Very helpful as always. Been watching you since the first Survival Game tutorial
@theodorescontras55697 жыл бұрын
Great tutorial, got weapon switching working in my game before even having my coffee.
@obsidian2957 жыл бұрын
Been following Brackeys since survival game, awesome channel !
@OilRacki7 жыл бұрын
Funny enough, I think I did 80% of this video on my own before seeing this. I think it just makes a lot of sense to do the way described here. It is good confirmation that I'd done things in a good way. There was one thing I did differently though.. I didn't have a "weapon holder" object, and just simply reference children below it, but I think that's just because of my game design. I have more weapons as children than the player can use, so I have something else to manage the weapons they're carrying and have armed. All in all, though, this is a great tutorial, and the method described here about the weapon holder is actually a really good idea. Thumbs up!
@TheReal-Infinite7 жыл бұрын
i'd love to see a continuation of the Multiplayer FPS Shooter with a Single Player Part of the Shooter
@renzocfn46693 жыл бұрын
Best coding tutorial channel I've ever seen in this world!
@Gathrey7 жыл бұрын
Thanx Brackeys. Good efficient tutorial. Exactly what I was looking for. Keep it up! Looking forward to future tutorials.
@КолянКоляныч-б1ь7 жыл бұрын
How to make a weapon appear when you pick it up and not just a full set of weapons? Good lessons, thank you.
@chaosmastermind4 жыл бұрын
You would set the weapons all to inactive and then make a power up collectible that activates only one type of weapon for each.
@ThatRazzy3 жыл бұрын
Hey were you able to figure this out?
@AshratAR7 жыл бұрын
I thought the whole process was much more difficult than this!! But this tutorial made it all simple!!!! Thanks!!
@chaosmastermind4 жыл бұрын
This is really useful and helpful. Thank you. Pretty much everyone that makes an FPS is going to need this.
@DavidAdochiti3 жыл бұрын
we miss u brackeys! come back plzzz
@thelightningfurycore39013 жыл бұрын
I don't think he ever will. He is leaving youtube, forever (or is he?) But there is a chance that he will come back
@faisalsajjad73967 жыл бұрын
thx brackeys loving this series
@alimirbagheri4533 жыл бұрын
You are just so awesome. words cant describe how you help. thank you brackey,s i miss you a lot. and hope that you are living your dream wherever you are.
@ppnhzk7 жыл бұрын
Nice tutorial as always. As I want to free up memory as much as I can, I do the switch by instantiating the weapon at a placed spawn point every time it is selected. Also, I store all the functions in the weapon object, even key presses like fire. It was easier because of the differences in their behaviour. After watching your tutorial however I might go with your method as it seems much more fluid in the end, though it might get heavy with 10+ weapons, so some testing might be needed. Not sure how much extra load the inactive stuff means.
@david35k5 жыл бұрын
Thank you! I really like your simple and clean tutorials! Very helpful
@RegenerationOfficial4 жыл бұрын
One of the most reused scripts Ive ever needed.
@artinmajidi16544 жыл бұрын
I had two animator components on my player, one for upper body and one for lower body. I made different controllers for each weapon and if that weapon is equipped, I simply switch animator controllers. Like this, I can do everything infinitely. And also, this took me a month to figure out. And another to do it.
@xiaobodong7265 жыл бұрын
Love your model, it’s so detailed
@WeaverKnight7777 жыл бұрын
can we make an animation for weapon switching
@flashgames12737 жыл бұрын
also shooting/aiming animations!
@davidenale177 жыл бұрын
Saad Tv yes will be nice to see it (and check if i'm doing it correctly)
@solomonlyons107 жыл бұрын
Saad Tv It's really really simple, I think a few really good videos on KZbin goes over it. I feel like the only challenging part for a lot of people is the mecanim portion.
@JayAnAm7 жыл бұрын
Actually it isn't that hard, will put it to my list.
@remove67967 жыл бұрын
switching with animations are easy you just need to make a default state anim and then make a sound fx play on awake and walla. you didn't understand did you? :(
@vanthele56239 ай бұрын
Thank you. The script is straightforward to understand
@TrifleWaffle7 жыл бұрын
thank you! I waited for this for so long!
@AnuragJhaCreations7 жыл бұрын
i watched 1 video of yours and my mouse automatically went to subscribe this guy
@lockedonbiome7 жыл бұрын
Could you do a tutorial on enemy ai with shooting
@BlackMesaEmployee6 жыл бұрын
Boss Hog306 do you still need that tutorial? I’m considering making one
@sconosciutosconosciuto21966 жыл бұрын
@@BlackMesaEmployee you don't make video :(
@anshivvv.vfx994 жыл бұрын
@@sconosciutosconosciuto2196 he said he was considering. Duh?
@theasin_old3 жыл бұрын
@@BlackMesaEmployee please
@ranger103013 жыл бұрын
@@BlackMesaEmployee do it
@yikes19107 жыл бұрын
been absolutely buzzing for this video since Wednesday
@GameS-lu2vz7 жыл бұрын
JammyDodger16 me too!
@mlgsquirrel4 жыл бұрын
i used this for switching attachments, but instead of scroll wheel its a button. great video man
@Oliver_TGB7 жыл бұрын
Really cool! I have an idea. How about you made a tutorial on how to make an ammo amount. In sense of being able to see how many bullets you can fire before there are none left and possibly a reloading animation.
@magnusm47 жыл бұрын
Simple, short and easy as it should be for programming
@mrsparklepants56367 жыл бұрын
HE MADE IT ATLAST I LOVE YOU BRACKEYS YOU ARE THE
@SuperManIsDope7 жыл бұрын
Love the new thumb nails !
@doxel86917 жыл бұрын
wow! I didn't know the transform class implemented the IEnumerator interface that returned the children, good to know. thanks brackeys!
@laurel88317 жыл бұрын
I love your thumbnails by the way
@aaravagrawal87993 жыл бұрын
Brackeys is so underrated
@FlyGuy87017 жыл бұрын
I really like the new thumbnails.
@justarandomguy92347 жыл бұрын
that feeling when you realize you put all the player variables (like health) in the shoot script and now u must break it apart
@seraphimsarecoool4 жыл бұрын
lol thats pretty easy to remove and CTR+V to a new script lol its been 3yrd
@nuclearbomb94833 жыл бұрын
@@seraphimsarecoool ctrl x
@Random-uo8sp5 жыл бұрын
You have no right to be so good
@NakaLore5 жыл бұрын
I used this for character swapping on my game. It is awesome!
@NakaLore5 жыл бұрын
Ok, it works and it doesn’t work at the same time. The characters switch, but only at the position of the parent object. But I dunno how to make them appear at right position.
@icantth1nkofanam404 жыл бұрын
@@NakaLore make a script that changes their position?
@woofiewill7 жыл бұрын
When you want to restrict an index to a range of numbers (like wrapping the index back to 0 when incrementing) it's almost always better practice to use modulus. Write `selectedWeapon = (selectedWeapon + 1) % transform.childCount` instead. This is a slight performance increase over using an if statement, and it's much more succinct. Even better would be this (I'll use some slight pseudocode): if (scrollUp) selectedWeapon++; else if (scrollDown) selectedWeapon--; selectedWeapon = selectedWeapon % transform.childCount; This way it's much simpler and you only need to apply modulus once to make sure the variable stays in your desired range.
@purpleguy90025 жыл бұрын
Thanks Brackeys! I love your videos!
@GoldenGamer267 жыл бұрын
Best tutorial channel, why dislikes!?!
@PandeyJiGames7 жыл бұрын
thnx a loot brackeys, awesome video again...
@Hasnain1F5 жыл бұрын
I am not even a Game Developer. Full-stack web developer instead but I love watching these videos! Why don't you make a game development course on Udemy? I am sure you will sell tons of it!!
@Incognitus305 жыл бұрын
Because, as stated in his description "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." Making a payed course on Udemy would pretty much make him a full on hypocrite.
@seifmustafa20047 жыл бұрын
your tutorials are super awesome 🙆
@drimihq77244 жыл бұрын
H,i I just started with Unity and C# last week and your videos are really helping me. I was wondering whether you could use a for loop instead of having to copy paste the "if statements" and whether it's beneficial (Timestamp 9:00) I used an array for the keycodes like this private UnityEngine.KeyCode[] Keycodes = {KeyCode.Alpha1, KeyCode.Alpha2, KeyCode.Alpha3, KeyCode.Alpha4, KeyCode.Alpha5, KeyCode.Alpha6, KeyCode.Alpha7, KeyCode.Alpha8, KeyCode.Alpha9, KeyCode.Alpha0}; and then I used a for loop and it works fine for (int i = 0; i
@Viski9822 жыл бұрын
Thanks man.
@ЄвгенГавриловський Жыл бұрын
Thank you, I tried it and it really worked and this code is not massive. However, I should specify that in my case it worked when I declared in "Update" method KeyCode array without "private" together with loop between "if" statements for mouse scroll wheel switching and if (previousWeapon != selectedWeapon).
@systematicloop32157 жыл бұрын
In the foreach statement in the SelectWeapon method, you could have simply said SetActive(selectedWeapon == i) instead of routing it to separate if statements.
@thevikaskandari4 жыл бұрын
Now that's called a awesome tutorial
@JustKatoh7 жыл бұрын
Thank you for the video, i have learned a lot
@gametips76275 жыл бұрын
All the way first class tutorial. Love your tutorial
@craze527 жыл бұрын
You are one of the best youtuber for scripting and youtube
@Kanal9947 жыл бұрын
Great tutorials. Cheers !
@emerickdorval37133 жыл бұрын
Barckeys you are my idole i like you so much i love your tutorials they teach me allot
@lucasgamesfr6s53 жыл бұрын
i really love the idea of pay what you want or grab it for free. I'm very sorry that i can't afford to support the model developpers but i'm grateful i can still use their creations
@alphachicken32257 жыл бұрын
Brackeys please do a tutorial (or tutorials) on 2D procedural generation with blocks, similar to Terraria or Starbound.
@lordofpenutbutter2 жыл бұрын
i think theres a tutorial about that on Sebastian league's channel
@Notchmods6 жыл бұрын
Thanks a lot sensei brackeys
@NachoMan1542 жыл бұрын
4:15 you could write that in one line: weapon.gameobject.SetActive(i == selectedWeapon);(instead of lines 22-25) should also be faster!
@DeaMikan7 жыл бұрын
loved it! can you make a tutorial all about post processing effects on the camera!
@bransoncostin20702 жыл бұрын
Thank you so much this helps me in my farming game!
@qweqweqwqeqweewe52182 жыл бұрын
why the fuck do you need a weapon in a farm game. wtf bro.
@bransoncostin20702 жыл бұрын
Don't ask questions...
@blaizefar457 жыл бұрын
Another Great Tutorial
@magnusm47 жыл бұрын
I like this way of making weapons best as it allows me to make each individual gun unique and not have to include every single stat on a single constructor file as some guns might be fired once or be selected as an ability so fire rate would be useless. Though i'm planning on having more than 30 or even 60 different weapons
@ildarildar15466 жыл бұрын
thank you Brackeys you rea lly helped me
@punisherioi4 жыл бұрын
Hello Brackeys, can you make a Weapon pick up tutorial please, like picking a weapon by pressing 'F' and and 'Q' to drop. To be simple, like COD weapon picking...(pick, drop, swap)... your videos are really amazing and easy to understand... thanks...
@ThatRazzy3 жыл бұрын
Hey did you figure this out? I'm trying to do the same thing :)
@lars-sorensen7 жыл бұрын
Elsker disse simple tutorials!
@ashwinanand42087 жыл бұрын
can you connect this to the fps series please
@remysadventures-official83577 жыл бұрын
Cool man! Btw a local Splitscreen tut? Just asking
@numadeveloper16 күн бұрын
3:17 Brackeys farting is the last thing I expected to hear today...
@tatepayton73682 жыл бұрын
Very helpful for both 2D and 3D
@farrukhkamal23154 жыл бұрын
Very good tutorial, helped me alot. Can you make a tutorial on how to add animations when switching weapons.Thanks again
@NiteHawkk1236 жыл бұрын
Amazing tutorial!
@sanderhoel62897 жыл бұрын
i find it quite funny how I have been struggling on an fps for half a year now, and boom you just solved all my problems.. p.s: i am sort of a beginner and the fps is not that complicated :)
@matarloum28947 жыл бұрын
This is working for you on uNet ??
@andreig29467 жыл бұрын
Hey can you make a video about how to make a car moove? Great job on your videos man!
@willmathonsi22867 жыл бұрын
Another brilliant video Asbjørn. Any idea on how to do ammo switching?
@jahangirakbar45247 жыл бұрын
your Channel is awesome! I am your Subscriber! Everything I need is Already Available on this Channel. Highly Recommended to Everyone!
@hackermub25985 жыл бұрын
5:50 well we can easily do that by selectedWeapon++; selectedWeapon%=transform.childCount; That means whenever selectedWeapon gets to the limit.. it will be set to 0
@xXLanyuzAnlunXx5 жыл бұрын
its just to make the beginners understand
@we2000h6 жыл бұрын
You are a great guy !! Love you
@migueldast88127 жыл бұрын
Great job! You are awesome! I ask you a question becouse i need help with my game. If i have not pick up the weapons yet, how can i activate the script (of weapon switching) after that? NOTE: I have the weapons in trigger box for seleccion. Please i need to solve it! Thanks!
@kaiser93217 жыл бұрын
A better way for wrapping around would be using variable % number, I remember using it in another coding language but I'm not sure if it works in C#, get back to me on that, thanks
@mastai76246 жыл бұрын
You are m'y best teacher with you i Can understand
@BenignoFilippo2 жыл бұрын
Congrats!!! When did you first start investing
@LLITALKER7 жыл бұрын
Ingeniously and simply !!!
@hiddeloman19677 жыл бұрын
Do you have a new thumbnail style or is it just for this type of video's? The look really cool!!!
@atlasthetitan51107 жыл бұрын
Nice video, could you make a ammo mechanic, like have some script count to a certain number then like disable the shooting script until you press the reload button, it could also trigger an animation
@randomguy-gb9ge2 жыл бұрын
I have something like that, if you want check out this tutorial:kzbin.info/www/bejne/pZ6QhIZjeKeNbsk
@abluecherry79376 жыл бұрын
you could also make it so if the gun isn't in view the gun wont fire then you could make a cube that has all 3 guns attached to it and it spins a certain amount when you press a button
@frostymug31232 жыл бұрын
Great tutorial thank you!
@julianpizano55867 жыл бұрын
Great tutorial! but I have a problem... The weapons that I have attached to the character controller aren't part of a weapon holder game object. (they are just children of the main camera) if I try to child the weapons to an empty game object, the positions of the weapons change... this causes the weapon animations to change drastically. Is there a way to child the weapons to an empty game object (weapon holder) without changing the position of the weapons themselves??????? plz reply!
@chaosmastermind4 жыл бұрын
You do have to add the number keys code for each weapon you add though. You don't need to add it for the mouse wheel though. There are ways to make that automated, but it's better not to get into it for a beginner tutorial.
@EDemircivi7 жыл бұрын
Simple & effective, thank you for your tutorials. Keep it up, and don't mind your view counts, you're great :).
@LorcanG4 жыл бұрын
i added a transition to it so its not static using UnityEngine; using System.Collections; public class WeaponSwitching : MonoBehaviour { public int selectedWeapon = 0; public float WeaponSwitchSpeed = 5f; public Vector3 position1; public Vector3 position2; public GameObject weapon1; public GameObject weapon2; public GameObject weapon3; public bool Selected1; public bool Selected2; public bool Selected3; void Start() { StartCoroutine(SelectWeapon()); } void Update() { int i = 0; int previousSelectedWeapon = selectedWeapon; if (Input.GetAxis("Mouse ScrollWheel") < 0f) { if (selectedWeapon >= transform.childCount - 1) selectedWeapon = 0; else selectedWeapon++; } if (Input.GetAxis("Mouse ScrollWheel") > 0f) { if (selectedWeapon = 2) { selectedWeapon = 1; } if (Input.GetKeyDown(KeyCode.Alpha3) && transform.childCount >= 3) { selectedWeapon = 2; } if (previousSelectedWeapon != selectedWeapon) { StartCoroutine(SelectWeapon()); SelectWeapon(); } #region Selection bools if (selectedWeapon == 0) { Selected1 = true; } else { Selected1 = false; } if (selectedWeapon == 1) { Selected2 = true; } else { Selected2 = false; } if (selectedWeapon == 2) { Selected3 = true; } else { Selected3 = false; } #endregion #region transitions if(Selected1 == true && weapon1.activeSelf == true) { weapon1.transform.localPosition = Vector3.Lerp(weapon1.transform.localPosition, position1, WeaponSwitchSpeed * Time.deltaTime); } else { weapon1.transform.localPosition = Vector3.Lerp(weapon1.transform.localPosition, position2, WeaponSwitchSpeed * Time.deltaTime); } if (Selected2 == true && weapon2.activeSelf == true) { weapon2.transform.localPosition = Vector3.Lerp(weapon2.transform.localPosition, position1, WeaponSwitchSpeed * Time.deltaTime); } else { weapon2.transform.localPosition = Vector3.Lerp(weapon2.transform.localPosition, position2, WeaponSwitchSpeed * Time.deltaTime); } if (Selected3 == true && weapon3.activeSelf == true) { weapon3.transform.localPosition = Vector3.Lerp(weapon3.transform.localPosition, position1, WeaponSwitchSpeed * Time.deltaTime); } else { weapon3.transform.localPosition = Vector3.Lerp(weapon3.transform.localPosition, position2, WeaponSwitchSpeed * Time.deltaTime); } #endregion } IEnumerator SelectWeapon() { yield return new WaitForSeconds(1f); int i = 0; foreach (Transform weapon in transform) { if (i == selectedWeapon) weapon.gameObject.SetActive(true); else weapon.gameObject.SetActive(false); i++; } } }
@LorcanG4 жыл бұрын
keep the position 1 at 0x 0y 0z and for position 2 x0.5 y-0.5 z-0.5 worked for me
@atomicalex17324 жыл бұрын
bro thats awesome, thanks
@Markleap2 жыл бұрын
my gun go in my head, how would i fix?
@LorcanG2 жыл бұрын
@@Markleap move the game object coordinates (the gun) forward
@AZASeraph2 жыл бұрын
For whatever reason it works when I scroll, but not with the keys and I've made sure it's the right code and all too
@nikodemhamrol90254 жыл бұрын
So if I had like 50 weapons in the game, how would you then go about handling those weapons. In terms of getting the transformation correct, animations, loaded into the scene. Because I dont imagine someone using this method. Im not complaining on the video, it's a great tutorial if you small amounts of weapons, but my curiosity is how to handle a bunch of weapons
@gaminganimator-qp2ir4 жыл бұрын
use the scroll wheel instead it will work fine then
@nikodemhamrol90254 жыл бұрын
@@gaminganimator-qp2ir so you would hold 50 weapons in one hand scroll through 50 weapons?
@gaminganimator-qp2ir4 жыл бұрын
@@nikodemhamrol9025 yea
@nikodemhamrol90254 жыл бұрын
@@gaminganimator-qp2ir name a game that does that
@gaminganimator-qp2ir4 жыл бұрын
@@nikodemhamrol9025 the game im working on
@mashoodkiyani39927 жыл бұрын
Your teaching style is amazing
@nikkiofthevalley4 жыл бұрын
oh god.. Just use Fusion 360, it's both easier to use and less time-consuming, but isn't free :(
@MARTOUFFF067 жыл бұрын
Why not use the modulus operator when cycling the weapons ? Which solution is more optimized ?
@MaZyYTube5 жыл бұрын
Both are same. Compiler will change to same machine code. Its about readability or comfortably
@user-th8nx4cp7w4 жыл бұрын
For some people like me you might have this problem where when foreach the transform, it acess the transform on the WeaponSwitcher too, so when you use your scroll wheel and keep scrolling up, you could end up in a empty space where the player is holding nothing. To deal with that, I add - public Transform weaponSwitcher -, and under the foreach -if(weapon.transform.IsChildOf(weaponSwitcer)){//rest of the code}