Unity Basic Weapon System Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 พ.ย. 2024

ความคิดเห็น • 366

  • @RaddyXD
    @RaddyXD 2 ปีที่แล้ว +93

    When the world needed him the most, he came back

  • @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.

  • @reallocal
    @reallocal 2 ปีที่แล้ว +12

    well well well, look who remembered his login.
    good to have you back plai

  • @CrammyCram
    @CrammyCram 3 หลายเดือนก่อน +1

    I like how you actually tell us what we're scripting instead of just showing us what to write down

  • @AtLeastITry-j7o
    @AtLeastITry-j7o ปีที่แล้ว +17

    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.

  • @Solidrigs
    @Solidrigs 2 ปีที่แล้ว +7

    Dude you are the only guy that actually deserves all sub, like and alarm buttons, truly worthy contents.

  • @ipga13
    @ipga13 2 ปีที่แล้ว +7

    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 ปีที่แล้ว +1

      not hard to code, legit just takes some simple triggers and input detection

    • @jakes-dev1337
      @jakes-dev1337 ปีที่แล้ว

      ​@@gerblesh_674 you are on a tutorial...

  • @dcry1003
    @dcry1003 2 ปีที่แล้ว +60

    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 ปีที่แล้ว +3

      Just use a short raycast and possibly a delay at the start to compensate for swingtime

    • @saulgoodman5662
      @saulgoodman5662 ปีที่แล้ว

      @@abel099 that's genius

    • @abel099
      @abel099 ปีที่แล้ว

      @@saulgoodman5662 Thanks but that's just how most games do it.

  • @zbeb118
    @zbeb118 2 ปีที่แล้ว +6

    Great video can't wait for the following videos about the effects

  • @RealRenixGaming
    @RealRenixGaming 2 ปีที่แล้ว +8

    Amazing videos, you probably know how hard it was to start game developing and right now that is me, thank you for helping. 🤗

  • @ZeonplayzYt
    @ZeonplayzYt 2 ปีที่แล้ว +2

    Thanks for coming back

  • @VVIZART_STUDIOS24
    @VVIZART_STUDIOS24 2 ปีที่แล้ว +8

    Amazing !! this was like a whole fps tutorial

  • @Jeast.
    @Jeast. ปีที่แล้ว +5

    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.

  • @LumpieMilk
    @LumpieMilk 2 ปีที่แล้ว +3

    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

  • @TheKr0ckeR
    @TheKr0ckeR ปีที่แล้ว

    Thank you. None of the shooting tutorials cover how to prevent spamming by clicking and attacking constantly.

  • @BatonyRobson
    @BatonyRobson 2 ปีที่แล้ว +3

    Man, thats a extremely good tutorial. Thank you very much. Maximum useful information in minumum time.

  • @Rahulsingh-theraha
    @Rahulsingh-theraha 2 ปีที่แล้ว +1

    I understand everything on first try ,that is just brilliant man

  • @fl0ixzzzz
    @fl0ixzzzz ปีที่แล้ว +1

    thank you so much plai these are the tutorials we need, nice keyboard sound by the way i like it

  • @dsguy369ds6
    @dsguy369ds6 2 ปีที่แล้ว +1

    bro im so glad your making videos, there so good haha

  • @avgchoobafan
    @avgchoobafan ปีที่แล้ว +6

    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 4 หลายเดือนก่อน

      Thx you are my hero

  • @spidernh
    @spidernh 2 ปีที่แล้ว +3

    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 ปีที่แล้ว +3

    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

  • @aoiSUB
    @aoiSUB 3 หลายเดือนก่อน

    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!

  • @funkynormalcat988
    @funkynormalcat988 10 หลายเดือนก่อน

    thank you, this is a well optimized code for any gun imo

  • @GoannaGoofOfficial123
    @GoannaGoofOfficial123 ปีที่แล้ว

    Thank you so much, you explain things quickly and don't take 20 minutes to create a basic weapon system +1 sub

  • @strompy2007
    @strompy2007 2 ปีที่แล้ว +1

    Yesss he comes back!

  • @AzureSkyed
    @AzureSkyed 9 หลายเดือนก่อน

    4:34 we should also subscribe to this channel.
    Good tutorial

  • @dipsheet1650
    @dipsheet1650 2 ปีที่แล้ว +5

    Hey man! Great tutorial! Could make a follow up video showing us how to add animations to the gun?

  • @plaidev
    @plaidev  4 หลายเดือนก่อน +1

    I realized I accidentally wrote `TakeDamage` instead of `Damage` at the end there. Sorry about that.

    • @cian9273
      @cian9273 4 หลายเดือนก่อน

      bruh

    • @trident35ro26
      @trident35ro26 7 วันที่ผ่านมา

      Thats why I got a error

  • @NikoVReality
    @NikoVReality 2 ปีที่แล้ว +6

    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 2 ปีที่แล้ว +1

      what other features for the visual bullet?

  • @octopro8937
    @octopro8937 2 ปีที่แล้ว +5

    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

  • @kryten719
    @kryten719 2 ปีที่แล้ว +1

    New video!!!
    Hype

  • @defaultsett1ng
    @defaultsett1ng ปีที่แล้ว +2

    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 ปีที่แล้ว

      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);

  • @L3RNA3AN
    @L3RNA3AN 2 ปีที่แล้ว

    9:11 - lmao, this totally caught me off guard!

  • @neilb5007
    @neilb5007 2 ปีที่แล้ว +4

    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

  • @Observer552
    @Observer552 2 หลายเดือนก่อน

    Can you please make a video explaining all these things in more detail? Because just copying and pasting doesn't help much. It might help a little bit, but learning what these things do (at least the things I don't understand) is more efficient.

  • @Daeniak
    @Daeniak 2 ปีที่แล้ว +2

    Really cool video continue !! :3

    • @plaidev
      @plaidev  2 ปีที่แล้ว +1

      thanks :)

    • @Daeniak
      @Daeniak 2 ปีที่แล้ว +1

      @@plaidev ;3

  • @benshi32
    @benshi32 ปีที่แล้ว +2

    There is something strange in the WeaponSway script, it turns my weapon 180 degrees facing me. please help

  • @drinkwatrr9883
    @drinkwatrr9883 2 ปีที่แล้ว

    Ayee thanks so much for this bro, it's super useful

  • @adarshagarwal5754
    @adarshagarwal5754 2 ปีที่แล้ว

    Killed it buddy
    i was checking for every gun active in hierarchy and then adding everything gun wise😅

  • @JacobAlkhal
    @JacobAlkhal ปีที่แล้ว +1

    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.

  • @insertname143
    @insertname143 2 ปีที่แล้ว

    How tf is this only 749 likes, this def deserves more

  • @SaharshDev
    @SaharshDev 2 ปีที่แล้ว +1

    YOO PLAI NEW VID LESS GOO

  • @schwagz
    @schwagz 2 ปีที่แล้ว

    YOOOOOOOO I’ve been watching you this week

  • @yaxpatel
    @yaxpatel 2 ปีที่แล้ว

    Lets go, new video!

  • @rendered3090
    @rendered3090 2 ปีที่แล้ว

    You're back, on my birthday :)

    • @plaidev
      @plaidev  2 ปีที่แล้ว

      Happy birthday!

  • @Dorbellprod
    @Dorbellprod 2 ปีที่แล้ว

    Lets go another pogger tutorial 🤩

  • @Birb-bc2jw
    @Birb-bc2jw ปีที่แล้ว +2

    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

  • @KhaledMohamed-gz7wk
    @KhaledMohamed-gz7wk 6 หลายเดือนก่อน

    you are the best teacher in the world

  • @monkmonkeen1531
    @monkmonkeen1531 2 ปีที่แล้ว +1

    I'm getting an error saying Target.cs(5,14), error CS0101, global namespace already contains a defintion for 'Target'

  • @ads4752
    @ads4752 2 ปีที่แล้ว

    Thank you I needed this 🙏

  • @ShrekBigscary
    @ShrekBigscary ปีที่แล้ว +1

    thanks!

  • @oApenasEu
    @oApenasEu 2 ปีที่แล้ว

    Sick Tutorial bro.

  • @joplemos
    @joplemos ปีที่แล้ว

    Great tutorial!

  • @hgfuwhvfuhvuhg
    @hgfuwhvfuhvuhg 2 ปีที่แล้ว

    Everyone...
    HE'S BACK!!

  • @hollowtea3687
    @hollowtea3687 11 หลายเดือนก่อน +1

    I have a problem where Target does not implement member IDamageable.Damage()’

  • @MrPotatoKing388
    @MrPotatoKing388 2 ปีที่แล้ว +3

    ive been trying for 2 hours to find out what and how to use pivot mode is

  • @hyperz737
    @hyperz737 2 ปีที่แล้ว +4

    can U make a video on crouching and sliding on ur character movement scripts.

  • @garfield6482
    @garfield6482 2 ปีที่แล้ว

    Plai is Back

  • @jenniferlovell7049
    @jenniferlovell7049 ปีที่แล้ว

    I'll need this in 2 years

  • @gamedevdemonold
    @gamedevdemonold 2 ปีที่แล้ว

    Welcome back

  • @dgbro524
    @dgbro524 9 หลายเดือนก่อน

    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?

  • @_dudm_
    @_dudm_ 2 ปีที่แล้ว

    Plai is back 😳

  • @Istoleyourbanan
    @Istoleyourbanan ปีที่แล้ว +1

    how would you do the shooting button for a ps4 controller right trigger

  • @unknowngamer8736
    @unknowngamer8736 ปีที่แล้ว +1

    I have a question , what version of unity will this work on?.

  • @anj_10
    @anj_10 2 ปีที่แล้ว +1

    Your the best,Thanksss

  • @tristian14
    @tristian14 2 ปีที่แล้ว

    babe wake up plai made a new video

  • @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?

  • @carlo1126
    @carlo1126 ปีที่แล้ว +1

    for me it says The modifier 'private' is not valid for this item for the private void update is there anyway to fix this?

  • @gabrielx24_44
    @gabrielx24_44 2 ปีที่แล้ว +1

    🧿
    Awesome tutorial

  • @vampire1256
    @vampire1256 2 ปีที่แล้ว +1

    "type or namespace name 'IDamageable' could not be found" tf do i do here

  • @RGBA
    @RGBA 2 ปีที่แล้ว

    less gooo you're back _DDDDDDDDD

  • @ShreedasShiva
    @ShreedasShiva ปีที่แล้ว

    error CS0246: The type or namespace name 'IDamageable' could not be found (are you missing a using directive or an assembly reference?

  • @buzzyrobo
    @buzzyrobo 2 ปีที่แล้ว +1

    What is the font you use in your intro and other text?

  • @swishhyy
    @swishhyy ปีที่แล้ว +2

    i got everything else working but the shooting it doesn't work for me

  • @AhmedMohamed-h3e
    @AhmedMohamed-h3e ปีที่แล้ว +1

    hey gus i've just started a game project and in 4:42 i don't understand anything and unity gives me an error : Playershoot does not contain a definition for shootinput

  • @maxg5196
    @maxg5196 2 ปีที่แล้ว

    So why would using Scriptable Objects like this be better than creating a gun base class that has all of the universal stats, then inheriting from that in the individual gun scripts. And you can set the stats for the guns individually in the inspector if they are public in the base class

  • @Messiahs100
    @Messiahs100 2 ปีที่แล้ว +1

    A realy great Video Plai ! But i stuck :_( I get the error message " Target' does not implement interface member 'IDamageable.Damage()' " and i dont get the red lines in the visual studio to folow your steps. 😞

  • @zephyr-d7v
    @zephyr-d7v 2 ปีที่แล้ว +1

    Hello! At the start of the video when you add the sway, mine worked, but also did not work. What happened was the sway is there but it turned my gun sideways??? How can you help???

    • @Szronk
      @Szronk 2 ปีที่แล้ว

      There is line with float MouseX
      In MouseX after the swayMultiplier change it to -360f (idk you need to test)

    • @Szronk
      @Szronk 2 ปีที่แล้ว

      Also in Quaternion rotation X change last few words to (mouseY, Vector3.left

  • @abel099
    @abel099 ปีที่แล้ว +2

    At 10:28 you type damagable?.TakeDamage(gunData.damage); but there is no reference for TakeDamage in IDamageable.
    I'm pretty sure you just meant the void "Damage" you created at 10:08 because I used it instead and it worked.
    Feel free to correct me.

  • @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

  • @actuallyalex9812
    @actuallyalex9812 2 ปีที่แล้ว

    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.

  • @AyushKumar-f5b
    @AyushKumar-f5b ปีที่แล้ว

    what is the extension that you are using in your visual studio for code ?

  • @theshenaniganizer1054
    @theshenaniganizer1054 2 ปีที่แล้ว

    yooooo plai is back

  • @gl1tchvr.
    @gl1tchvr. หลายเดือนก่อน

    i need help, when i put thre muzzle stuff in i got this error message: "Assets\scripts\Gun.cs(28,39): error CS1061: 'RaycastHit' does not contain a definition for 'muzzle' and no accessible extension method 'muzzle' accepting a first argument of type 'RaycastHit' could be found (are you missing a using directive or an assembly reference?)" is there any way to fix this?

    • @trident35ro26
      @trident35ro26 12 วันที่ผ่านมา

      It says that you are missing a reference. If you press ALT + ENTER while having the cursor on the code that gives the error, it should help you to fix it

  • @ineryz123
    @ineryz123 ปีที่แล้ว +2

    How do I set the reload key by default to be R?

  • @jaxisplayingtoday
    @jaxisplayingtoday ปีที่แล้ว +1

    getting this error. Assets\scripts\Gun.cs(54,32): error CS1061: 'IDamageable' does not contain a definition for 'TakeDamage' and no accessible extension method 'TakeDamage' accepting a first argument of type 'IDamageable' could be found (are you missing a using directive or an assembly reference?)

    • @archy_YIN
      @archy_YIN ปีที่แล้ว +1

      Same error 😢did you fix it?

    • @grizzlydonnutt
      @grizzlydonnutt ปีที่แล้ว

      ​@Archy_ I have the same did you end up working it out?

    • @grizzlydonnutt
      @grizzlydonnutt ปีที่แล้ว

      Problem*

    • @archy_YIN
      @archy_YIN ปีที่แล้ว +1

      @@grizzlydonnutt Yes, I have. Just change the ‘IDamageable’ from the damageable?.’IDamagebale’ to ‘Damage’ and it will be ok.

    • @FotballVC
      @FotballVC ปีที่แล้ว +1

      To fix the error, you should add the TakeDamage method to the IDamageable interface. For example:
      java
      Copy code
      public interface IDamageable
      {
      void TakeDamage(float damageAmount);
      }
      It worked for me :D

  • @EduEdo27
    @EduEdo27 2 ปีที่แล้ว +1

    I've followed every step but my gun still ain't reloading

  • @hehehe_hussain1694
    @hehehe_hussain1694 หลายเดือนก่อน

    in the playershoot script im getting this error:
    Assets\PlayerShoot.cs(8,19): error CS0246: The type or namespace name 'Action' could not be found (are you missing a using directive or an assembly reference?)

    • @fireburst6868
      @fireburst6868 หลายเดือนก่อน

      Please show your code, because I had the same issue but cant remember how I solved it

    • @hehehe_hussain1694
      @hehehe_hussain1694 หลายเดือนก่อน

      @@fireburst6868 i already solved it i just asked chat gpt

    • @inlo3948
      @inlo3948 24 วันที่ผ่านมา

      @@fireburst6868 just add "using system;" at the start of your code, he forgot to include it.

  • @Kikkelimies
    @Kikkelimies 9 หลายเดือนก่อน

    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?

  • @astropixelop8870
    @astropixelop8870 2 ปีที่แล้ว

    YOOO LETS GO ANOTHER UPLOAD YOURE SICK

  • @Tortle226
    @Tortle226 2 ปีที่แล้ว +1

    once i complete the final step of the tutorial and save my code, it says that "TakeDamage" is not something it identifies it, was there somewhere I was supposed to reference it

    • @westron7257
      @westron7257 2 ปีที่แล้ว +1

      change "TakeDamage" to just "Damage"

    • @bigglasses2625
      @bigglasses2625 5 หลายเดือนก่อน

      @@westron7257 That didn't work for me

  • @randomdud581
    @randomdud581 2 ปีที่แล้ว +3

    Can anyone pls help? When I drag the Scriptable object into Gun data field, it shows that it should be the same class name.
    By the way nice video!

    • @plaidev
      @plaidev  2 ปีที่แล้ว

      Thanks! Maybe the name of the file and the name of the class are different? They should be the same.

  • @Tybek1
    @Tybek1 2 ปีที่แล้ว

    Yay its Plai

  • @nespero576
    @nespero576 2 ปีที่แล้ว

    YEEEEEEEEEEEEEEEEEEEEES YOU CAME BAAAAAAAAAAAAAAAAACK

  • @StupidDuckDev
    @StupidDuckDev 2 ปีที่แล้ว +1

    How do I get the weapon sway code to work with an animator?

  • @Nebula_Protogen752
    @Nebula_Protogen752 2 ปีที่แล้ว

    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 2 ปีที่แล้ว +3

      just say "using System" at the beggining (worked for me)

  • @SokkHuman1117
    @SokkHuman1117 ปีที่แล้ว

    The game is telling me that the modifier 'public' on the IDamageable script is not valid for the item, can anyone help?

  • @wasiali7507
    @wasiali7507 2 ปีที่แล้ว

    The goat 🐐

    • @plaidev
      @plaidev  2 ปีที่แล้ว

      yooo