MODULAR WEAPON SYSTEM in Unity in Under 4 Minutes

Поделиться
HTML-код
  • Опубликовано: 9 авг 2022
  • In this video, I show you how to make an easily customizable gun/weapon system in Unity.
    Join my Discord! ► / discord
    ::More Resources::
    How to make a smooth FPS Character Controller ► • SMOOTH FIRST PERSON MO...
    ? Operator ► docs.microsoft.com/en-us/dotn...
    Raycasting ► docs.unity3d.com/ScriptRefere...
    UnityEvent ► docs.unity3d.com/ScriptRefere...
    C# Properties ► docs.microsoft.com/en-us/dotn...

Комментарии • 80

  • @Rytech_Dev
    @Rytech_Dev  7 месяцев назад +3

    Code is in the discord for those who need it! (Link in the description)

    • @MonkeMan71
      @MonkeMan71 7 месяцев назад

      I can't find the code

    • @Rytech_Dev
      @Rytech_Dev  7 месяцев назад +1

      @@MonkeMan71 go to #code-archives in the discord after getting the rewction role

    • @MonkeMan71
      @MonkeMan71 7 месяцев назад

      @@Rytech_Devthanks

  • @LegoDinoMan
    @LegoDinoMan 2 года назад +17

    Wonderful tutorial, I enjoyed that you took a second to explain each step.

  • @BorfleYT
    @BorfleYT Год назад +3

    YOU ARE A LEGEND!!! THANK YOU SO MUCH!! ive been trying to learn how raycasts work and this is so simple and easy to follow. Very underrated!!

  • @TheBlazingWolfie
    @TheBlazingWolfie Год назад +3

    I'll tell ya what, this is a really solid video. Good job mate

  • @sirtorus
    @sirtorus Год назад

    I don't think I deserve this Tutorial, So much info in so little time!

  • @Allanbest-sw4qf
    @Allanbest-sw4qf Год назад +1

    So Helpful! ❤

  • @kalpolproductions8558
    @kalpolproductions8558 2 года назад +4

    I never knew about a Unity Event :/ thanks man i can do alot that just guns with this new info bro.

  • @schmoovie
    @schmoovie Год назад +1

    UR A LIFE SAVER THANK YOU SO MUCH!!!

  • @ukleIsStinky
    @ukleIsStinky 10 месяцев назад +3

    hey just wondering how could u add muzzle flash and damage indicators when shooting enemies?

  • @goldybold
    @goldybold Год назад

    very helpful thanks👍👍

  • @mrtaluspa9903
    @mrtaluspa9903 Год назад

    Thanks soooo much♥

  • @somerandomguy3977
    @somerandomguy3977 Год назад +5

    anyone know why there wouldnt be a shoot() function under the damage gun tab on the event handler, as shown at 2:50?

    • @lpa1970
      @lpa1970 Год назад

      I did that wrong
      Go to the Damage Gun script and make it to public instead of private in the shoot function

  • @timurcraft2018
    @timurcraft2018 Год назад

    Great!

  • @jordanbentley
    @jordanbentley 8 месяцев назад

    You are a gentlemen and a scholar

  • @Notable838
    @Notable838 10 месяцев назад

    why am i getting a stack over flow error

  • @G1060available
    @G1060available Год назад +2

    Please make a video how to add particles to it

  • @ThatBlenderDude_
    @ThatBlenderDude_ 7 месяцев назад +2

    hey there, where can we download the code for copy and paste? i have some errors and dont wanna debug them all

    • @whysl
      @whysl 3 месяца назад

      From his discord server. But it actually have a bit of errors, so stay attentive!

  • @deviousdinoo
    @deviousdinoo 5 месяцев назад

    tried this, didint work- tried joining the discord to see the code- didint work.. it just says theres an object refrence not set to an instance of an object.. NVM! Set your camera to maincamera in its tags, that should do the trick!

  • @SkorpionYassine
    @SkorpionYassine 2 месяца назад

    Cool tutorial, if you could add some chill music maybe. That would be nice in your future videos ^^

  • @CodenTheSynth
    @CodenTheSynth Год назад +1

    I whould love it if i could see the ammo :)

  • @Dragon20C
    @Dragon20C 5 месяцев назад +1

    this is very clever, I am using this method in godot!

  • @Notable838
    @Notable838 10 месяцев назад

    can i have the entity script

  • @user-mp4yq9du3v
    @user-mp4yq9du3v 4 месяца назад

    while making the gun damage I noticed that there was an error on enemy.Health -= Damage; does anyone know what is wrong, I am new to unity.

    • @prokeyG
      @prokeyG 2 месяца назад

      make a script for entitiy or remove line

  • @lasernugg
    @lasernugg 4 месяца назад

    Timestamp: ~2:25. Hey, I chose to use the "Damage Gun" version, and I'm getting an error that says: error CS0246: The type or namespace name 'Entity' could not be found (are you missing a directive or an assembly reference?).

    • @lasernugg
      @lasernugg 4 месяца назад

      nvm i figured it out :P

    • @whysl
      @whysl 3 месяца назад

      @@lasernugg How?

    • @whysl
      @whysl 3 месяца назад

      alright, all you need to do, is create a new script, and name it as "Entity". And just copy the code from the video

    • @lasernugg
      @lasernugg 3 месяца назад

      @@whysl I’m pretty sure you just do both gun versions, that fixed it for me I believe

  • @bababommboi6495
    @bababommboi6495 13 дней назад

    It says entity could not be found

  • @Wanabechef
    @Wanabechef Год назад +3

    I don’t understand what is going on. My script is working fine except that my gun instantly kills my enemy even though it’s damage and the health are both the exact same as the video.

    • @sushiman3817
      @sushiman3817 9 месяцев назад

      Where you ever able to figure out the issue? I'm getting the same thing.

    • @DanielMTB663
      @DanielMTB663 8 месяцев назад

      same here@@sushiman3817

    • @DanielMTB663
      @DanielMTB663 8 месяцев назад

      if you are still having trouble you have to change the fire cool down on the gun@@sushiman3817

    • @mandogaming2539
      @mandogaming2539 Месяц назад

      Isn’t that how it works if you do the same amount of damage to an enemy and it has the same heath it should be dead? Right?

  • @medkingart
    @medkingart Год назад

    I can't find "shoot()" in OnGunshoot from 'gun' script

    • @Notable838
      @Notable838 Год назад

      did you find it?

    • @GOF313
      @GOF313 9 месяцев назад

      You've likely not named things correctly. The intellisence will direct you, hit alt plus enter over it, I think thats the command that should help you.

  • @shwetankpandey4606
    @shwetankpandey4606 Год назад +2

    Bro mine shows error idk why I did it all perfect

    • @DrawingKid4
      @DrawingKid4 7 месяцев назад

      Is the script and in the script the same name?

  • @Notable838
    @Notable838 Год назад +1

    can you give me the script for the entity class plsss

    • @Notable838
      @Notable838 Год назад

      its giving me this error StackOverflowException: The requested operation caused a stack overflow.
      entity.get_Health () in :0

  • @Fuzzypro11
    @Fuzzypro11 Год назад

    this does not works for me :(

  • @kjcrafts751
    @kjcrafts751 Год назад +2

    Script??

  • @UhGoomba
    @UhGoomba 2 года назад +3

    Holy fucking shit

    • @Rytech_Dev
      @Rytech_Dev  2 года назад +2

      😁😄😃😃🙂🙃😉🙃😉😉🥵🤢🤢🤢🧐😕🥶🥸🥺🥺🥸😧😰😥😭😭😮😱😱☹🙁😵‍💫

    • @Noalogy
      @Noalogy Год назад

      @@Rytech_Dev 1

  • @depa468
    @depa468 2 месяца назад +2

    using System.Collections.Generic;
    using UnityEngine;
    public class Entity : MonoBehaviour
    {
    [SerializeField] private float StartingHealth;
    private float health;
    public float Health
    {
    get
    {
    return health;
    }
    set
    {
    health = value;
    Debug.Log(health);
    if (health

  • @matapavosgamer
    @matapavosgamer Год назад

    Very easy to understand for begginers, but the code isn't very clean and it might teach them bad habits

  • @SOS_Studios
    @SOS_Studios 5 месяцев назад

    aint no way in hell im typing all that. put it in the description.

    • @Rytech_Dev
      @Rytech_Dev  5 месяцев назад

      All tutorial code is in my discord server

    • @Trackstar50hundred
      @Trackstar50hundred 3 месяца назад

      @@Rytech_Dev Doesnt work, its blocked off for me, says im not allowed in the channels for the code

  • @TheNelson916-tn8sm
    @TheNelson916-tn8sm 7 месяцев назад

    theres half an hour of my life i spent that im never getting back. idk wtf all these people are talking abt

  • @TheSixoul
    @TheSixoul Год назад

    Not so much a weapon system as it's just how to create a single gun.

  • @sergio4027
    @sergio4027 11 месяцев назад +1

    Another Dude that thinks he can code but just wastes peoples time, there is not health reference code full of errors, if you need a tutorial look for someone more knowledgeable. SKIP this GUY

    • @DanielMTB663
      @DanielMTB663 8 месяцев назад +1

      nah this works

    • @cattebayo
      @cattebayo 7 месяцев назад +1

      it works. check if your code is right lol

    • @TheNelson916-tn8sm
      @TheNelson916-tn8sm 7 месяцев назад

      what unity version are u using
      @@cattebayo

  • @Noalogy
    @Noalogy Год назад +1

    Hey, @Rytech. I can't figure out whats wrong with my dmg script. I've check 4 times and still cant figure out what it is.
    Here is my error code: NullReferenceException: Object reference not set to an instance of an object
    DamageScript.Shoot () (at Assets/DamageScript.cs:18)

    • @Noalogy
      @Noalogy Год назад

      Please try to respond in the next 3 days as for I will probably have quit later than that. Since your tutorials are easy to learn and actually have given me some knowledge of C#

    • @tughloksiddiquee1714
      @tughloksiddiquee1714 Год назад

      Go to paste bin, and poste your code there, and put the link here, maybe i can help

    • @Noalogy
      @Noalogy Год назад

      @@tughloksiddiquee1714
      I can't at the moment, so i'll just show you it here.
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class DamageScript : MonoBehaviour
      {
      public float Damage;
      public float BulletRange;
      private Transform PlayerCamera;
      private void Start()
      {
      PlayerCamera = Camera.main.transform;
      }
      public void Shoot()
      {
      Ray gunRay = new Ray(PlayerCamera.position, PlayerCamera.forward);
      if (Physics.Raycast(gunRay, out RaycastHit hitInfo, BulletRange))
      {
      if (hitInfo.collider.gameObject.TryGetComponent(out Entity enemy))
      {
      enemy.Health -= Damage;
      }
      }
      }
      }

    • @6clix331
      @6clix331 Год назад

      ​@@Noalogy are you sure you referenced everything? the error says that you haven't referenced something on line 18 of your "DamageScript"

    • @crabboz6451
      @crabboz6451 Год назад +1

      i know this is 10 months late, but I just solved the same problem for anyone else; the camera that your player sees with must be tagged as the maincamera in the inspector menu, thats what the damagegun script is accessing

  • @depa468
    @depa468 2 месяца назад

    using System.Collections.Generic;
    using UnityEngine;
    public class DamageGun : MonoBehaviour
    {
    public float Damage;
    public float BulletRange;
    private Transform PlayerCamera;
    private void Start()
    {
    PlayerCamera = Camera.main.transform;
    }
    public void Shoot()
    {
    Ray gunRay = new Ray(PlayerCamera.position, PlayerCamera.forward);
    if (Physics.Raycast(gunRay, out RaycastHit hitInfo, BulletRange))
    {
    if (hitInfo.collider.gameObject.TryGetComponent(out Entity enemy))
    {
    enemy.Health -= Damage;
    }
    }
    }
    }
    damage gun