Realistic Gun in VR - Part 1

Sdílet
Vložit
  • čas přidán 28. 10. 2020
  • Learn in this video how to make realistic fire weapon in Unity using the XR Interaction Toolkit.
    ▶ Get access to the source code: / valemvr
    ▶ Join the Discord channel: / discord
    Download the Gun Sounds and the XROffset Grab Script :
    drive.google.com/drive/folder...
  • Hry

Komentáře • 125

  • @ValemVR
    @ValemVR  Před 3 lety +95

    First :)

    • @GoldFishNoMore
      @GoldFishNoMore Před 3 lety

      I don't have the Xr grab intractable component can you help?

    • @somerandomguy2892
      @somerandomguy2892 Před 3 lety

      I HAVE A HUGEEEEE ISSUE with firing the Gun, the bullet spawn lags behind just a small distance behind, no matter what direction I move in, depending on speed and height, like if I am running or Jumping, or just side strafing, the bullet spawnpoint shifts side to side, it sucks, please help. If you could point me in the right direction or offer your advice, I would be forever in your debt. So, Basically the bullets are spawning from where I was a second or so before, rather than from where I am. It makes the bullet spawnpoint to shift side to side, Help....Please.
      Here is the code I am using
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class Gun : MonoBehaviour
      {
      public float speed = 80;
      public GameObject bullet;
      public Transform barrel;
      public AudioSource audioSource;
      public AudioClip audioClip;
      public void Fire()
      {
      Instantiate(bullet, barrel.position, barrel.rotation).GetComponent().AddForce(barrel.forward * speed);
      audioSource.PlayOneShot(audioClip);
      Destroy(bullet, 2);
      }
      }

    • @cutecandygames1874
      @cutecandygames1874 Před 3 lety

      @Valem i know you have a lot to do but if you manage to answer this that would be awesome
      How would this work with the OVR plugins from oculus

    • @Salmontoes
      @Salmontoes Před rokem

      nice

    • @FroggysFanGameTuts
      @FroggysFanGameTuts Před rokem

      @@GoldFishNoMore you have to go to package manger press the plus type com.unity.xr.interaction.toolkit

  • @joshokodo
    @joshokodo Před 3 lety +53

    was trying to make a vr gun with realistic loading like this myself. lets just say...im glad this new tutorial came out

  • @rainefalls9672
    @rainefalls9672 Před 3 lety +9

    I learned about your channel just yesterday, and today when I was researching how to make a realistic gun for a VR game you happened to upload that today lol. Awesome tutorials :)

  • @HardyCozen
    @HardyCozen Před 3 lety +4

    I have been learning so much from these videos and have a few prototypes up and running on the Quest. Thank you, Valem!

  • @immortalhamster1645
    @immortalhamster1645 Před 3 lety +14

    I’ve been into game development for a while, I recently received a quest 2 and man, the feeling of stepping into your own project is, truly unreal. Thank you so much.

    • @the_game1259
      @the_game1259 Před 2 lety +2

      No, it's not Unreal, its Unity! lol

  • @elliot2024
    @elliot2024 Před 3 lety +1

    i have been waiting for a video like this for so long

  • @Henry_c1
    @Henry_c1 Před 3 lety +11

    This is exactly what ive been looking for

  • @AtomsForFuel
    @AtomsForFuel Před 3 lety +1

    Oh my god yes I’ve been looking for this, I just learned how to instantiate game objects using a VR button, and this would be really cool for doing randomly spawned targets like cubes

  • @richardosborn159
    @richardosborn159 Před 3 lety

    Thanks! This is some good insight into VR.

  • @brendanpedrazzoli8735
    @brendanpedrazzoli8735 Před 3 lety +3

    7:33 - No truer words have ever been said!😂 Love your work, Valem

  • @calledtim_
    @calledtim_ Před 3 lety +1

    Actually this is the best CZcams Channel

  • @Sendit77
    @Sendit77 Před 21 dnem

    this enabled me to use my first code in vr man thanks heaps bro

  • @e1ic1
    @e1ic1 Před 3 lety +3

    My favorite gun out there, -Valem 2020

  • @elephin
    @elephin Před rokem +2

    For anyone with PINK MATERIAL happening to them, it is basically that you are using a newer version or adifferent pipeline, to solve it I had to change the material itself from standard to URP-Lit and put in the base-map of the Lit material what would be in the albedo option for the standard material.

  • @GreenDave113
    @GreenDave113 Před 3 lety +11

    I wanted to ask, with the Hinge Joint you used, when the hand grabbing is is like 0.5 units away or further, the Joint starts glitching and teleports the object around.
    It is attached to a grabbable object.

  • @GloryMeat
    @GloryMeat Před 3 lety +4

    Thank you for making this! I needed this so much :)

  • @ayayrawnnn9725
    @ayayrawnnn9725 Před 3 lety +1

    without you Valem, i would be oh so lost

  • @joegiusti528
    @joegiusti528 Před 3 lety

    Awesome, thank you

  • @remyvillulles7399
    @remyvillulles7399 Před 3 lety +2

    I suppose you are putting the 2 box colliders to be able to pull the top of the gun when loading? It could be nice if you could justify it in your videos. People are beginners and explaining even quickly this kind of thing could really be great (I'm a beginner too haha, I'm learning VR with you!)

  • @PolyVR2
    @PolyVR2 Před 2 měsíci

    "A programmer makes the code. But a good programmer takes the code" Valem - Oct 29, 2020

  • @Retro--
    @Retro-- Před 2 lety +1

    Will you be making an updated full series on VR development? Alot of stuff I feel is outdated from the original set of tutorials

  • @user-rd6jd2wg9p
    @user-rd6jd2wg9p Před 3 lety

    Какой же ты молодец!!!!!!!! Respect

  • @maximusthegreatest
    @maximusthegreatest Před 3 lety

    Hi Valem, it would be really cool if you could do something on physics based vr, something like a boneworks system.

    • @ScratchGenius
      @ScratchGenius Před 3 lety

      That would be pretty cool, although, after all, that's an entire physics system that he has to make, which already took a whole team of developers years to make.

  • @neomasaki3234
    @neomasaki3234 Před 2 lety +1

    Hey Valem, I tried making these scripts work on a shotgun but the shotgun just switches hands instead of letting me grab the pump. Any ideas on what could be causing that?

  • @AmaroLoops
    @AmaroLoops Před 3 lety

    does this also work for valve index, working with unity's xr plugin (cause u did a tutorial for steamvr before )??

  • @rawadaridi2068
    @rawadaridi2068 Před 3 lety +1

    hello valem i used to be a patreon but i can no longer pay from credit cards in my country (Lebanon). I was wanted to say thank you for these great videos, also i wanted to ask you if you can make a vr body kinda like last series you did but with xr since so much have changed. Thank you

  • @willjulian8
    @willjulian8 Před 3 lety +4

    All the textures of the prefabs are appearing pink, but it hasn't before when i have used this package. anybody help?

    • @dinobyte3010
      @dinobyte3010 Před 3 lety +3

      You gotta update the textures to urp.
      Open your Project in Unity, and go to Edit > Render Pipeline > Universal Render Pipeline then click upgrade materials

  • @HP-vt7pt
    @HP-vt7pt Před 3 lety +1

    hi as a beginner developer should i buy rift s or quest?

  • @LordZandaurgh
    @LordZandaurgh Před 3 lety +1

    Everytime I hear him say "Nokobot" I think he's saying knucklebutt

  • @FC12CGaming
    @FC12CGaming Před 3 lety

    im planning on using this asset for my game, the asset isn't copyrighted is it?

  • @geri4367
    @geri4367 Před 3 lety

    Some recoil would be nice too :D

  • @Inuitman
    @Inuitman Před 3 lety

    Can you use the XR script to make it playable in Oculus quest?

  • @Muempier
    @Muempier Před 3 lety

    with the xr grab can i use distance grab instead?

  • @exil_s4247
    @exil_s4247 Před 2 lety

    how do i point it in the right direction or say where it have to grab bc i dont wanna have a really relistic gun and have a different gun model i also wanna have a sword but its grabing on defaut where the axis is. pls how do i fix this

  • @randompathmain1575
    @randompathmain1575 Před 2 lety

    Could you make a download where we would just have to move an entire xr rig and we wouldn't have to set it up ourselves. I'm having issues with getting the hands to be in the right place.

    • @randompathmain1575
      @randompathmain1575 Před 2 lety

      They are further out and to the left some. I've tried everything I know to fix it and it dosent work

  • @Salmontoes
    @Salmontoes Před 4 měsíci

    is there a way this will work with the IK Rig? because im working on a multiplayer shooter inspired by Pavlov and TTT from Garry's Mod

    • @pietrosprudente
      @pietrosprudente Před 3 měsíci

      It should. If you followed this tutorial, the ik tutorial and custom pose tutorial this should work perfect, best of luck in your game!

  • @WeaselWatches
    @WeaselWatches Před 3 lety

    I used the Pivot point for the gun so my hand was visible but my bullet just goes flying upwards? does anyone have the same problem?

  • @user-th1ef7du5y
    @user-th1ef7du5y Před 3 měsíci

    I am developing the game but how can i test it without the vr glasses?

  • @meeperhere
    @meeperhere Před 3 lety

    first vid where you use quest 2 :)

  • @Dem0VR
    @Dem0VR Před rokem

    Hey m8 can you make a updated version of this for the tutorials channal

  • @cazforshort
    @cazforshort Před 2 lety

    For some reason this just instantly breaks my project on import (App stuck on 3 Dots). I don't even need to add any gameobjects from the asset to the scene. Just importing the asset alone causes it to break. I've tried other assets and they don't cause the issue.

  • @card-ride_conversations8634

    why is it that everything I try to script ends up never working? I type the exact same things as you do and It just doesn't work.

  • @keelanbowker-obrien2222
    @keelanbowker-obrien2222 Před 3 lety +1

    When I use my own gun model with discrete RB and Kinematic movement on the XR Grab Interactable, there is a lot of stutter whenever I move the object around or whenever the player moves :(

    • @MrVic-qu9qh
      @MrVic-qu9qh Před 3 lety

      I've had a issue too where If I move a object with my hands its stuttery even though my hands are running completely smooth.

    • @keelanbowker-obrien2222
      @keelanbowker-obrien2222 Před 3 lety

      @@MrVic-qu9qh yup, this.

    • @MrVic-qu9qh
      @MrVic-qu9qh Před 3 lety

      @@keelanbowker-obrien2222 I think the issue is that the objects are running at a different max framerate but I don't know how to increase the objects frame rate.

  • @Inuitman
    @Inuitman Před 3 lety +1

    Can you give me a link to XR tutorial?

  • @DoubledEthan
    @DoubledEthan Před 3 lety +6

    Are you reincarnation of Brackeys? 🤔

  • @CicadasFly
    @CicadasFly Před 3 lety +1

    Yes yes yes yes yes yes

  • @jaysfiree
    @jaysfiree Před rokem

    Is it possible for my to use my own model and create this gun?

  • @connorwilson-long1336
    @connorwilson-long1336 Před 3 lety +1

    Is there any way to add haptic feedback when you shoot the gun.

    • @fakefaker700
      @fakefaker700 Před 2 lety

      Yes, on the XR Direct Interactor, usually on each controller, there are options for haptics.

  • @yeetmastervr
    @yeetmastervr Před 2 lety

    Can I use the script for a other model

  • @thegamingcoder4789
    @thegamingcoder4789 Před 2 lety

    valem: you might be mad because I didn’t create my own script
    Animators & 3D modelers:...
    Btw I love ur vidds

  • @mrmarcus3899
    @mrmarcus3899 Před rokem

    Does it work with index?

  • @daphnedigi3599
    @daphnedigi3599 Před 3 lety

    I can't open the simple shoot script, does anyone has the same issue? Or does someone have a solution?

  • @Lushsf
    @Lushsf Před rokem

    How is your hand invisible?

  • @jasperekkel
    @jasperekkel Před 2 lety +2

    For anyone who wants the bullets to despawn. Place under // Create a bullet and add force on it in direction of the barrel this:
    GameObject tempBullet;
    tempBullet = Instantiate(bulletPrefab, barrelLocation.position, barrelLocation.rotation);
    tempBullet.GetComponent().AddForce(barrelLocation.forward * shotPower);
    Destroy(tempBullet, destroyTimer);

    • @vozifyvr
      @vozifyvr Před rokem

      does this go under the code underneath that comment?

  • @yosoyshadow4992
    @yosoyshadow4992 Před 3 lety

    Is it Oculus quest 2 ?

  • @xezienstudios
    @xezienstudios Před rokem

    GetButton doesn't work with the new input system

  • @joshbrooks2827
    @joshbrooks2827 Před 3 lety

    Can anyone confirm if the handpresance script still works

  • @enemynotfunny7048
    @enemynotfunny7048 Před 3 lety

    Does this work for oculus quest

  • @rxdane9320
    @rxdane9320 Před rokem

    it says parameter fire does not exist
    what do i do

  • @gaminmaxwell8004
    @gaminmaxwell8004 Před 3 lety +2

    What does the code say after tempCasing.GetComponent().AddExplosionForce(Random.Range(ejectPower * 0.7f, ejectPower), (casingExitLocation.position - casingExitLocation.right

    • @gaminmaxwell8004
      @gaminmaxwell8004 Před 3 lety

      HELP

    • @purexfate
      @purexfate Před 3 lety

      Anyone have an answer to this I'm in the same boat

    • @purexfate
      @purexfate Před 3 lety +1

      @Asset Reviewer i got it my friend "tempCasing.GetComponent().AddExplosionForce(Random.Range(ejectPower * 0.7f, ejectPower), (casingExitLocation.position - casingExitLocation.right * 0.3f - casingExitLocation.up * 0.6f), 1f);"

  • @Doofles
    @Doofles Před 3 lety

    gun has no recoil?

  • @Lol-yf5td
    @Lol-yf5td Před rokem

    Does it work for steamvr?

  • @RagnarGaming2801
    @RagnarGaming2801 Před 3 lety

    hi man great work, but how to add recoil ?

    • @nubcake14
      @nubcake14 Před 3 lety

      (sorry im really late) not really sure, maybe you could add it in the animation, or try having a force constantly pushing it to the default position, then rotate/move it upwards so that the recoil would work with multiple consecutive shots

  • @joshbrooks2827
    @joshbrooks2827 Před 3 lety

    Nice

  • @ZaCkOX900
    @ZaCkOX900 Před 3 lety

    Mine are insane, I started VR dev when VR first came out, I've been doing realistic guns for many years now. I even do real projectiles.

    • @AtomsForFuel
      @AtomsForFuel Před 3 lety

      Looking forward to seeing you add your skills for realistic guns into your Unity Tutorials you’ve already made!

  • @eeroojanm98
    @eeroojanm98 Před 3 lety

    How can you delete the hand when holding a gun?

    • @nubcake14
      @nubcake14 Před 3 lety

      (sorry im really late) you probably wouldnt want to delete it, or even disable it because thats also whats being tracked. Maybe instead you could just disable the mesh renderer so you wouldnt see it

  • @KEINKOLLEKTIV
    @KEINKOLLEKTIV Před rokem

    my gun is complety purple
    anyone know why

  • @CicadasFly
    @CicadasFly Před 3 lety +1

    Is this a jojo reference

  • @NAGYT101
    @NAGYT101 Před rokem +1

    it doesnt show pull tigger as a function

  • @cinaryc9830
    @cinaryc9830 Před 3 lety

    Great

  • @SentientAsWell
    @SentientAsWell Před 10 měsíci

    for some reason the gun has been falling through the floor do you know why?

    • @doubleaxe18
      @doubleaxe18 Před 10 měsíci

      You must add a Rigidbody component to your floor and make sure that the option is Kinematic is selected and the option use gravity is not selected

    • @SentientAsWell
      @SentientAsWell Před 10 měsíci

      @@doubleaxe18 thx(:

  • @Flowshow88
    @Flowshow88 Před 2 lety

    Why is it that I can buy an arcade gun with very realistic recoil for a hundred dollars from a hundred places but a can’t a recoil gun in VR is near impossible???

  • @ruffvr5932
    @ruffvr5932 Před 2 lety

    WHY DOES THE GUN FALL THROUGH THE CUBE

    • @BlackDev
      @BlackDev Před 2 lety

      floor collision maybe

  • @Henry_c1
    @Henry_c1 Před 3 lety

    Yessss

  • @p00t0typ3
    @p00t0typ3 Před 3 lety

    when i change the trigger function to what you did, it just gives me a error saying, "Assets\Nokobot\Modern Guns - Handgun\_Demo Assets\SimpleShoot.cs(81,1): error CS1022: Type or namespace definition, or end-of-file expected"
    Is there anyway i can fix this?
    edit: im still waiting for a answer

  • @Grace_3D
    @Grace_3D Před 11 měsíci

    MAKE THE SAME TUTORIAL WITH OVRPLAYER OCULUS

  • @sixsugarssixburners2318
    @sixsugarssixburners2318 Před 3 lety +6

    Thank you very much for the tutorials, they're excellent. However, I do have a complaint: can you please remove your face from the tutorials? Nothing personal you're a handsome guy, but most of the times you're covering the properties panel and it's so annoying. I really hope this new bad habit in CZcams tutorials stops. Thanks again for the content brother.

    • @sea-jae6237
      @sea-jae6237 Před 3 lety +1

      I completely disagree, I did not find a single time in this tutorial that I needed to see the properties panel and couldn't, no hate towards you I just wanted to let Valem know that not everyone that watches thinks the same as your comment :)

  • @maxwhite5988
    @maxwhite5988 Před 3 lety +1

    Thank you so much for this tutorial, I tried on my own and It didn’t work at all.

    • @ValemVR
      @ValemVR  Před 3 lety +4

      What was the issue? :o

    • @maxwhite5988
      @maxwhite5988 Před 3 lety +1

      I am brand new at learning code was the issue honestly.

    • @maxwhite5988
      @maxwhite5988 Před 3 lety +1

      I wrote it the wrong way, your tutorial worked it was my attempts before this that didn’t work

  • @MtOwlest
    @MtOwlest Před 2 lety +1

    sexyy, also 100th comment

  • @levioliveiradosreis1084

    48th

  • @nace6849
    @nace6849 Před 3 lety +2

    rEaLiStIc ShOoTiNg
    Recoil be like: im bouta end this mans whole career

  • @TylerS_4589
    @TylerS_4589 Před 3 lety

    second :)

  • @camerafilmanim
    @camerafilmanim Před rokem

    For anyone wondering what the code is after
    "tempCasing.GetComponent().AddExplosionForce(Random.Range(ejectPower * 0.7f, ejectPower), (casingExitLocation.position - casingExitLocation.right"
    it's:
    " - casingExitLocation.up * 0.6f), 1f);
    tempCasing.GetComponent().AddTorque(new Vector3(0, Random.Range(100f, 500f), Random.Range(100f, 1000f)), ForceMode.Impulse);
    Destroy(tempCasing, destroyTimer);
    }
    }"

  • @PommeVerte47
    @PommeVerte47 Před 3 lety +1

    Is he French?

  • @VoidKeeperNull
    @VoidKeeperNull Před 3 lety

    18th