Give Among Us A Weapon Pistol & Shotgun | Game Clone Made In Unity Software | Weapon Switch Feature @AlexanderZotov
Give Among Us A Weapon Pistol & Shotgun | Game Clone Made In Unity Software | Weapon Switch Feature  @AlexanderZotov
Uploaded October 2020 | Updated September 2026, 3 weeks ago
#AmongUs #UnityWeapon #UnityWeaponSwitch
Episode 2. Give Among Us A Weapon Pistol & Shotgun.

Hi!
In a previous video I created this running spaceman like in Among Us Game. In this video I give him a couple of guns (Pistol and Shotgun) and let him switch them by pressing a button.

I play games here - twitch.tv/zzotoff
You are very welcome :-)

Previous video here youtu.be/W3-EncfpBZM

Pistol And Shotgun here drive.google.com/file/d/1iZKtxnYFkolnpj6L2R5gGy8zaVj2bF_9/view?usp=sharing

If you like what I'm doing then you can support me through
patreon.com/alexanderzotov
or here
paypal.me/AZotov
Thank you)

Hi!
In a previous video I created this running spaceman. In this video I give him a couple of guns and let him switch them by pressing a button.

So this is the previous project (link to that video is in the description). What new here is a couple of weapon sprites. Pistol and shotgun. Bring them to the scene. There we go. Weapons are a little too big so I scale them down. OK. Shotgun and pistol will be carried about here. So to give spaceman a weapon I need to instantiate it. To instantiate a gameobject I need a prefab of it. Prefabs will be loaded from Resources folder. So I create one in Assets folder. It’s very important not to make a typo in the folder name. One mistake and it will not work. Folder is created and I D&D pistol and shotgun gameobjects into it making them prefabs. I can delete these gameobjects from hierarchy. To instantiate a weapon, to give it a correct position and other stuff I use a script. Here it is. Boring variables here. Fun begins in Update method. If Q button is pressed then the switch weapon method is invoked that consists of more fun.

Here I check a value of which weapon selected variable. If it’s one then it means that a pistol will be spawned. But first I have to remove a weapon if it’s already in the character's hand. When it’s done a new weapon is instantiated which is a pistol in this case. Pistol prefab is loaded from Prefabs subfolder of resources folder. In fact I forgot to create that Prefabs folder so I’m going to get an error later. But I’ll fix it. I Promise. Ok. After instantiation I make this weapon to be a child of the character so it follows the player wherever he goes. Then I set a local position of a pistol so it appears in the character's hand. Well, kind of. Next line is about to give a weapon a higher value of order in layer option so it’s rendered in front of characters sprite. Then I reset weapons local scale so it faces outwards the player. Last line increases which weapon selected value so next weapon will be selected when Q button is pressed one more time.

All the same stuff happens in case if which weapon selected equals to 2. Difference is in shotgun instantiation of course. Pistol is removed. Shotgun is in hands. The last thing here is that if which weapon selected exceeds the number of guns then it’s set back to one. So it’s kind of a weapon selection cycle. That’s the script.
D&D this script to the character. I already did that. Now I hit play and show you how to get errors because as I said before I forgot to put my weapon prefabs into Prefabs subfolder. I press Q and error appears. I fix that by creating Prefabs subfolder in resources folder and putting pistol and shotgun prefabs into it. There we go. Now it should work fine. And it does. I can switch a weapon by pressing Q button. Unfortunately I have only two guns. Anyway I hope you like this tutorial. Thank you for watching and see you next time.
Give Among Us A Weapon Pistol & Shotgun | Game Clone Made In Unity Software | Weapon Switch FeatureUnity Tutorial How To Create Simple Jetpack Game With Obstacles For AndroidUnity 2D Tutorial How To Make Character Jump Tapping Or Touching The Screen In Android GameHow To Move Obstacles Or Even Enemy Back And Forth in Sine Cycle With Simple C# Script In Unity GameReduce HP Health Points By Mouse Click | Health Is Zero Player Is Destroyed | Unity 2D TutorialMake a simple puzzle game about vending machine with Unity Software At Live StreamUnity Tutorial How To Move Or Drag Gameobject With MouseCreating a simple escape puzzle game with Unity Software while Chatting and Chilling At Live StreamMake a simple color sequence puzzle game with Unity Software At Live StreamApex Legends Kills And Deaths WTFs Top Fails And Funny Moments #1Unity 2D Tutorial How To Create The Wheel Of Fortune Prize Giving Feature For Android GamePlay Random Sounds When Player Picks Up Coins In Game Made With Unity Software Simple Sound Manager
Alexander Zotov |

Give Among Us A Weapon Pistol & Shotgun | Game Clone Made In Unity Software | Weapon Switch Feature

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER