Тёмный

Unity Basic Weapon System Tutorial 

Plai
Подписаться 7 тыс.
Просмотров 156 тыс.
50% 1

I present to you my longest video yet. Sorry for all the mistakes in the video, I usually don't make such long videos.
In this video, I teach you how to create a simple weapon system. In future episodes, we'll add weapon switching, and visual/sound effects.
PROJECT LINK: github.com/Plai-Dev/weapon-sy...
Like & Subscribe!
Timestamps
00:00 Intro
00:23 Scene Setup
02:03 Scriptable Object
03:42 Shooting
07:12 Reloading
08:24 Damaging
10:35 Outro
Socials:
Discord: / discord
=============================================================
#unity #tutorial #weaponsway #unityfps #fpstutorial #unitytutorial

Хобби

Опубликовано:

 

4 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 350   
@RaddyXD
@RaddyXD 2 года назад
When the world needed him the most, he came back
@CrammyCram
@CrammyCram День назад
I like how you actually tell us what we're scripting instead of just showing us what to write down
@aaron4488
@aaron4488 8 месяцев назад
It's therapy for me to watch you code these scripts. It's an art form. Thank you very much for the content. It was better than what I expected.
@DiazDryx
@DiazDryx 2 года назад
Dude you are the only guy that actually deserves all sub, like and alarm buttons, truly worthy contents.
@RealRenixGaming
@RealRenixGaming 2 года назад
Amazing videos, you probably know how hard it was to start game developing and right now that is me, thank you for helping. 🤗
@zbeb118
@zbeb118 2 года назад
Great video can't wait for the following videos about the effects
@reallocal
@reallocal 2 года назад
well well well, look who remembered his login. good to have you back plai
@user-nn9mf2yt5r
@user-nn9mf2yt5r Год назад
If anyone has the issue of their weapon facing their camera parallel after trying to implement weapon sway, you're issue may be that when you switched your gun 180 when positioning it, you may have put your sway script in the same directory. For Example, if you changed the direction of your gun in your weapon holder section, and also put the sway script in that same area, and are having this issue, correct the direction of the gun in its folder instead of weapon holder folder. Hope this helped anyone who needed it, and sorry if it's kinda confusing I'm not great at explaining things.
@ipga13
@ipga13 2 года назад
nice and fast, to the point, no unneccasary explaining. perfect! wish every tutorial was like this. edit: suggestion maybe an interaction system
@gerblesh_674
@gerblesh_674 2 года назад
not hard to code, legit just takes some simple triggers and input detection
@jakes-dev1337
@jakes-dev1337 Год назад
​@@gerblesh_674 you are on a tutorial...
@Jeast.
@Jeast. Год назад
Thanks for this, its been really fun making shotguns, assault rifles and pistols using this script, youre a really big help to the indie devs.
@VVIZART_STUDIOS24
@VVIZART_STUDIOS24 2 года назад
Amazing !! this was like a whole fps tutorial
@ZeonplayzYt
@ZeonplayzYt 2 года назад
Thanks for coming back
@motoro1279
@motoro1279 Год назад
thank you so much plai these are the tutorials we need, nice keyboard sound by the way i like it
@LumpieMilk
@LumpieMilk 2 года назад
Nice video actually showing you a more modular weapon system rather than just showing you how to do a raycast and that's it, like most other tutorials. My spaghetti code thanks you
@Rahulsingh-theraha
@Rahulsingh-theraha 2 года назад
I understand everything on first try ,that is just brilliant man
@BatonyRobson
@BatonyRobson Год назад
Man, thats a extremely good tutorial. Thank you very much. Maximum useful information in minumum time.
@dsguy369ds6
@dsguy369ds6 2 года назад
bro im so glad your making videos, there so good haha
@GoannaGoofOfficial123
@GoannaGoofOfficial123 Год назад
Thank you so much, you explain things quickly and don't take 20 minutes to create a basic weapon system +1 sub
@drinkwatrr9883
@drinkwatrr9883 2 года назад
Ayee thanks so much for this bro, it's super useful
@TheKr0ckeR
@TheKr0ckeR 10 месяцев назад
Thank you. None of the shooting tutorials cover how to prevent spamming by clicking and attacking constantly.
@dcry1003
@dcry1003 2 года назад
Damn this is very convenient i was just about to continue my 3D project after trying out 2D thank you very much! Hey plai can you make a tutorial about melee weapons next like sword swing, throw damage etc.
@abel099
@abel099 Год назад
Just use a short raycast and possibly a delay at the start to compensate for swingtime
@saulgoodman5662
@saulgoodman5662 11 месяцев назад
@@abel099 that's genius
@abel099
@abel099 11 месяцев назад
@@saulgoodman5662 Thanks but that's just how most games do it.
@neilb5007
@neilb5007 2 года назад
this tutorial is great but i cant figure out how to make semi automatic weapons how do I reference the gundata scriptable object in the player shoot script to check if a weapon is automatic or not so that if it is semi automatic it only shoots when the mouse is pressed once
@KC-ii7rk
@KC-ii7rk Год назад
short and to the point as a dev should be good job best tutorials on yt
@benshi32
@benshi32 Год назад
There is something strange in the WeaponSway script, it turns my weapon 180 degrees facing me. please help
@adarshagarwal5754
@adarshagarwal5754 2 года назад
Killed it buddy i was checking for every gun active in hierarchy and then adding everything gun wise😅
@user-kd6qw4zi7q
@user-kd6qw4zi7q 10 месяцев назад
what is the extension that you are using in your visual studio for code ?
@Sonchiv
@Sonchiv Год назад
error CS0246: The type or namespace name 'IDamageable' could not be found (are you missing a using directive or an assembly reference?
@StupidDuckDev
@StupidDuckDev 2 года назад
How do I get the weapon sway code to work with an animator?
@buzzyrobo
@buzzyrobo 2 года назад
What is the font you use in your intro and other text?
@ads4752
@ads4752 2 года назад
Thank you I needed this 🙏
@funkynormalcat988
@funkynormalcat988 7 месяцев назад
thank you, this is a well optimized code for any gun imo
@actuallyalex9812
@actuallyalex9812 Год назад
Says that error CS0246: The type or namespace name 'RangedWeapons' could not be found (are you missing a using directive or an assembly reference?) (I renamed it to ranged weapons cause imma add melee weapons after) even though its right there! thanks for taking your time if you'd like to help.
@carlo1126
@carlo1126 Год назад
for me it says The modifier 'private' is not valid for this item for the private void update is there anyway to fix this?
@L3RNA3AN
@L3RNA3AN 2 года назад
9:11 - lmao, this totally caught me off guard!
@dipsheet1650
@dipsheet1650 Год назад
Hey man! Great tutorial! Could make a follow up video showing us how to add animations to the gun?
@monkmonkeen1531
@monkmonkeen1531 Год назад
I'm getting an error saying Target.cs(5,14), error CS0101, global namespace already contains a defintion for 'Target'
@ineryz123
@ineryz123 Год назад
How do I set the reload key by default to be R?
@kryten719
@kryten719 2 года назад
New video!!! Hype
@schwagz
@schwagz 2 года назад
YOOOOOOOO I’ve been watching you this week
@Istoleyourbanan
@Istoleyourbanan 10 месяцев назад
how would you do the shooting button for a ps4 controller right trigger
@unknowngamer8736
@unknowngamer8736 Год назад
I have a question , what version of unity will this work on?.
@dgbro524
@dgbro524 6 месяцев назад
Help!! When I get collide with wall or anyother object, the raycast goes through and draw the line and won't damage the enemies, how can I fix it?
@joplemos
@joplemos Год назад
Great tutorial!
@JacobAlkhal
@JacobAlkhal 10 месяцев назад
on the script gun I got error CS0103 the type or namespace name "Damageable" could not be found twice at 15,9 and 16,9 and then it says. the name 'Playershoot' does not exist in current context what do I do. I'm using notepad by the way.
@strompy2007
@strompy2007 2 года назад
Yesss he comes back!
@oApenasEu
@oApenasEu 2 года назад
Sick Tutorial bro.
@yaxpatel
@yaxpatel 2 года назад
Lets go, new video!
@insertname143
@insertname143 2 года назад
How tf is this only 749 likes, this def deserves more
@aoiSUB
@aoiSUB 24 дня назад
Thanks for the nice tutorial! Just a quick question here! I'm wondering what's the main difference of making "gun script" with every variable in the "gun data script" and attach it to each weapon and change the parameter, versus doing exactly what you did in the video where you make "gun data" a scriptable object and use those variables in the "gun script"? I'm interested in mastering OOP and Scriptable Object more so I'd love to learn the advantage of doing the latter method!
@Dorbellprod
@Dorbellprod 2 года назад
Lets go another pogger tutorial 🤩
@C-S-G
@C-S-G Год назад
Im getting the error that Vector3 does not contain the definition for 'Up' and rotationX does not exist in the current context
@Birb-bc2jw
@Birb-bc2jw Год назад
Great Vid but can you help me with something, when i do this - [SerializeField] GunData gunData; it doesnt show me the section to put gun data
@octopro8937
@octopro8937 2 года назад
hey this vid great and i love it but if anyone got any errors that say something like muzzle variable or muzzle not assigned just go to your gun's inspector then where it says transform select your muzzle then no error
@archieharrap5901
@archieharrap5901 Год назад
Idk if ive done something but i completed the tutorial worked all fine and my gun could shoot and reload, then randomly it stopped shooting and i cant find a way to fix?
@Kikkelimies
@Kikkelimies 6 месяцев назад
Does somebody know why when i write the [CreateAssetMenu part it gives me CS1012 which is too many charecters in literal and i try the softwares fixes which didnt work so does anybody know a fix?
@rybavihevima
@rybavihevima Год назад
Can someone help me? im having a issue with the code. im getting this error: "Assets/Scripts/IDamageable.cs(8,17: errorCS0106: the modifier 'public' is not valid for this item" I have no idea what it means
@rendered3090
@rendered3090 2 года назад
You're back, on my birthday :)
@plaidev
@plaidev 2 года назад
Happy birthday!
@SaharshDev
@SaharshDev 2 года назад
YOO PLAI NEW VID LESS GOO
@Daeniak57
@Daeniak57 2 года назад
Really cool video continue !! :3
@plaidev
@plaidev 2 года назад
thanks :)
@Daeniak57
@Daeniak57 2 года назад
@@plaidev ;3
@spidernh
@spidernh 2 года назад
how convinient, I opened unity for the first time in a while yesterday to try and recreate an old game that was supposed to have weapons (wasn't smart enough back then) I'm still gonna use my terrible system but probably do something similar to your damage interface
@octopro8937
@octopro8937 2 года назад
hey bro great tutorial but can u please help me its says The type or namespace name "Action " could not be found (edit) im so dumb unity hating on me not putting "using System;" up at the top but i fixed it no issues
@gabrielx24_44
@gabrielx24_44 2 года назад
🧿 Awesome tutorial
@SokkHuman1117
@SokkHuman1117 Год назад
The game is telling me that the modifier 'public' on the IDamageable script is not valid for the item, can anyone help?
@HawaHawa-Dev
@HawaHawa-Dev 2 года назад
Very good video cool!
@anj_10
@anj_10 2 года назад
Your the best,Thanksss
@hgfuwhvfuhvuhg
@hgfuwhvfuhvuhg 2 года назад
Everyone... HE'S BACK!!
@gamedevdemonold
@gamedevdemonold 2 года назад
Welcome back
@Husky11116
@Husky11116 2 года назад
How do you get the scriptable object to work
@KhaledMohamed-gz7wk
@KhaledMohamed-gz7wk 3 месяца назад
you are the best teacher in the world
@jenniferlovell7049
@jenniferlovell7049 Год назад
I'll need this in 2 years
@defaultsett1ng
@defaultsett1ng Год назад
I am getting two errors, one says "error CS0106: The modifier 'public' is not valid for this item" and the other says "error CS0535: 'Target' does not implement interface member 'IDamageable.Damage(float)' I also get an error when I try to add the target script to the target object, that reads "Can't add script component 'Target' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match." Please help, I've been trying to fix this for ages to no avail. The 'public' in "public void damage(float damage);" inside IDamageable is uncolored in visual studio so that seems to be part of why it's not working.
@the_martina
@the_martina 11 месяцев назад
If you have the error "cs0106 " The modifier 'public' is not valid for this item , simply delete the public should keep this = void TakeDamage(float damage);
@Hyphen3372
@Hyphen3372 2 года назад
ay new vid very nice and helpfull
@garfield6482
@garfield6482 2 года назад
Plai is Back
@tristian14
@tristian14 2 года назад
babe wake up plai made a new video
@ShrekBigscary
@ShrekBigscary Год назад
thanks!
@Bobduncan69420
@Bobduncan69420 2 года назад
what do you do if the gun doesnt move with the cam
@avgchoobafan
@avgchoobafan 9 месяцев назад
7:01 to avoid this, delete the variable currentAmmo from the GunData script and instead put a variable inside Gun named localAmmo. In Start() just assign localAmmo to be equal to gunData.magSize. Replace gunData.currentAmmo with localAmmo where needed.
@TaiwaneseLLfan
@TaiwaneseLLfan Месяц назад
Thx you are my hero
@_dudm_
@_dudm_ 2 года назад
Plai is back 😳
@RGBA
@RGBA 2 года назад
less gooo you're back _DDDDDDDDD
@Coolkidstan
@Coolkidstan Год назад
my Gun script isnt letting me connect a reference like gun data or anything else
@demonpuke4954
@demonpuke4954 2 года назад
After sometesting, ive tried splitting the sphere into different Targets, (same setrup as Target>Sphere) But it destroys all the game objects when one is destroyed. Made a TargetBlock, they all share the same health pool, how can i easily fix this? Thank you in advance!
@PollenDev
@PollenDev 10 месяцев назад
You Probably already fixed it, but for the rest of people, just use [SerializeField] public float health = 100f; for the variable
@Nebula_Protogen752
@Nebula_Protogen752 Год назад
When making the PlayerShoot script, Microsoft Visual Studio gave me an error saying that "Action" i not a valid name for a public static field? did I miss something?
@yass3459
@yass3459 Год назад
just say "using System" at the beggining (worked for me)
@asifmehrabi5154
@asifmehrabi5154 Год назад
it is showing me this error Assets\Scripts\Gun.cs(50,77): error CS0246: The type or namespace name 'IDamageable' could not be found (are you missing a using directive or an assembly reference?) Pls help!
@provideowatcher
@provideowatcher Год назад
I have the same issue tell me if you solve it
@CoreyBarlow
@CoreyBarlow Год назад
Does any one have any tips on how to add an ammo UI on screen with this script?
@hollowtea3687
@hollowtea3687 7 месяцев назад
I have a problem where Target does not implement member IDamageable.Damage()’
@NikoVReality
@NikoVReality 2 года назад
Great! It was not ok for me to use a Raycast, 1-st because of my gun in the center of the screen (so it was always a "target" for cameras), and 2-nd I wanted a physical bullet, but not a "virtual" one. So I mixed your code with some other simple features, worked perfect!!!
@MennoWeerman
@MennoWeerman Год назад
what other features for the visual bullet?
@MrPotatoKing388
@MrPotatoKing388 2 года назад
ive been trying for 2 hours to find out what and how to use pivot mode is
@plaidev
@plaidev Месяц назад
I realized I accidentally wrote `TakeDamage` instead of `Damage` at the end there. Sorry about that.
@cian9273
@cian9273 Месяц назад
bruh
@KalebMorrow30
@KalebMorrow30 Год назад
I copied the script and keep getting: Assets\scripts\scriptable objects\gun data.cs(5,34): error CS0246: The type or namespace name 'menuName' could not be found (are you missing a using directive or an assembly reference?) . any suggestions?
@damnthishandleistaken
@damnthishandleistaken Год назад
Did you fix it?
@RatchetEden
@RatchetEden Год назад
hi first this is a very good tutorial in the content aspect but its really hard to understand because youre talking both to fast with not enough detail and in monotone making it hard to understand and really boring
@UglyDouglyss
@UglyDouglyss Год назад
I couldn’t get the shooting to work I tried looking at he code but I couldn’t find any difference
@Nebula_Protogen752
@Nebula_Protogen752 Год назад
I can't find the weapon sway script on the github page? looked in the assets/scripts directory and it wasn't there
@plaidev
@plaidev Год назад
The link for it is in the description of my Weapon Sway video
@theshenaniganizer1054
@theshenaniganizer1054 2 года назад
yooooo plai is back
@bogalok588
@bogalok588 Месяц назад
ty so much
@orangeparrots5898
@orangeparrots5898 9 месяцев назад
i cant get the inspecter window for the weapon at arround 3:10
@bingchilling989
@bingchilling989 2 года назад
does the raycast always hit anything that is on the middle of the screen (crosshair) even if it is on the muzzle which is offset from the middle
@caution0001
@caution0001 2 года назад
Not neccesarily, Personaly i would cast a ray from the forward direction of the camera to have consistancy between all weapons and where they aim. This way, you also have more freedom to position the weapon how you want so it looks better in the camera view
@plaidev
@plaidev 2 года назад
Yea as @C4uTi0N said it won't hit the centre of the screen. Depending on the position of the gun it'll be slightly offset. If you would like it to be exactly the centre you can use the camera's position as the origin and the camera's forward as the direction of the Ray.
@bingchilling989
@bingchilling989 2 года назад
Ok Thx
@Heroicplayzrbx
@Heroicplayzrbx Месяц назад
I have a error in Gundata what do I do
@hyperz737
@hyperz737 2 года назад
can U make a video on crouching and sliding on ur character movement scripts.
@clarkmeyer7211
@clarkmeyer7211 Год назад
could you implement a drop gun and equip gun system as well?
@ToprakDev_Games
@ToprakDev_Games Год назад
Thank :)
Далее
I Tried Making a Multiplayer FPS Game in 1 Week...
8:40
Как похудеть на 10 кг ?! БЫСТРО!
07:06
Редакция. News: 128-я неделя
57:33
Просмотров 1,6 млн
Weapon Switching in Unity | Weapon System #2
4:31
Просмотров 28 тыс.
He said I Couldn't Make a 3D Game... So I Made One!
10:29
I Made Call of Duty Warzone in 48 Hours
8:50
Просмотров 295 тыс.
Dear Game Developers, Stop Messing This Up!
22:19
Просмотров 699 тыс.
ADD ARMS TO YOUR GAME - EASIEST WAY (Unity3D)
15:22
Просмотров 54 тыс.
Все очень включено
0:43
Просмотров 1,7 млн
Проверил, как вам?
1:00
Просмотров 18 млн