Realistic Gun in VR - Part 1

Поділитися
Вставка
  • Опубліковано 3 жов 2024
  • 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.c...

КОМЕНТАРІ • 125

  • @ValemVR
    @ValemVR  3 роки тому +94

    First :)

    • @GoldFishNoMore
      @GoldFishNoMore 3 роки тому

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

    • @somerandomguy2892
      @somerandomguy2892 3 роки тому

      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 3 роки тому

      @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 2 роки тому

      nice

    • @FroggysFanGameTuts
      @FroggysFanGameTuts Рік тому

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

  • @joshokodo
    @joshokodo 3 роки тому +53

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

  • @Henry_c1
    @Henry_c1 3 роки тому +11

    This is exactly what ive been looking for

  • @GreenDave113
    @GreenDave113 3 роки тому +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.

  • @rainefalls9672
    @rainefalls9672 3 роки тому +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 :)

  • @remyvillulles7399
    @remyvillulles7399 3 роки тому +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!)

  • @richardosborn159
    @richardosborn159 3 роки тому

    Thanks! This is some good insight into VR.

  • @PolyVR2
    @PolyVR2 6 місяців тому

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

  • @DoubledEthan
    @DoubledEthan 3 роки тому +6

    Are you reincarnation of Brackeys? 🤔

  • @immortalhamster1645
    @immortalhamster1645 3 роки тому +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 2 роки тому +2

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

  • @HardyCozen
    @HardyCozen 3 роки тому +4

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

  • @elephin
    @elephin Рік тому +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.

  • @LordZandaurgh
    @LordZandaurgh 3 роки тому +1

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

  • @e1ic1
    @e1ic1 3 роки тому +3

    My favorite gun out there, -Valem 2020

  • @AllenCayea
    @AllenCayea 24 дні тому

    How can I make it shoot faster? I looked through the script and it seems like it would be the "ShootPower", but I increased it by a lot and still doesn't work. I am wondering if it has to go through the whole animation before it can shoot again. If so, I guess there is no way around this unless you go into each animation and make it shorter. Anyone else have a better idea? Great video, appreciate it. @ValemVR

  • @joegiusti528
    @joegiusti528 3 роки тому

    Awesome, thank you

  • @Retro--
    @Retro-- 2 роки тому +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

  • @brendanpedrazzoli8735
    @brendanpedrazzoli8735 3 роки тому +3

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

  • @GloryMeat
    @GloryMeat 3 роки тому +4

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

  • @sixsugarssixburners2318
    @sixsugarssixburners2318 3 роки тому +7

    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 UA-cam tutorials stops. Thanks again for the content brother.

    • @sea-jae6237
      @sea-jae6237 3 роки тому +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 :)

  • @rawadaridi2068
    @rawadaridi2068 3 роки тому +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

  • @HP-vt7pt
    @HP-vt7pt 3 роки тому +1

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

  • @KEINKOLLEKTIV
    @KEINKOLLEKTIV Рік тому

    my gun is complety purple
    anyone know why

  • @maximusthegreatest
    @maximusthegreatest 3 роки тому

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

    • @ScratchGenius
      @ScratchGenius 3 роки тому

      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 3 роки тому +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?

  • @NAGYT101
    @NAGYT101 Рік тому +1

    it doesnt show pull tigger as a function

  • @gaminmaxwell8004
    @gaminmaxwell8004 3 роки тому +2

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

    • @gaminmaxwell8004
      @gaminmaxwell8004 3 роки тому

      HELP

    • @purexfate
      @purexfate 3 роки тому

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

    • @purexfate
      @purexfate 3 роки тому +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);"

  • @Blazing-o1e
    @Blazing-o1e 6 місяців тому

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

  • @Sendit77
    @Sendit77 3 місяці тому

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

  • @AtomsForFuel
    @AtomsForFuel 3 роки тому +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

  • @MtOwlest
    @MtOwlest 2 роки тому +1

    sexyy, also 100th comment

  • @jaysfiree
    @jaysfiree Рік тому

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

  • @Inuitman
    @Inuitman 3 роки тому +1

    Can you give me a link to XR tutorial?

  • @jasperekkel
    @jasperekkel 2 роки тому +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 Рік тому

      does this go under the code underneath that comment?

  • @Grace_3D
    @Grace_3D Рік тому

    MAKE THE SAME TUTORIAL WITH OVRPLAYER OCULUS

  • @Olive1234VR
    @Olive1234VR Місяць тому

    does it work with Photon Pun 2

  • @Salmontoes
    @Salmontoes 7 місяців тому

    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 6 місяців тому

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

  • @calledtim_
    @calledtim_ 3 роки тому +1

    Actually this is the best UA-cam Channel

  • @ayayrawnnn9725
    @ayayrawnnn9725 3 роки тому +1

    without you Valem, i would be oh so lost

  • @CicadasFly
    @CicadasFly 3 роки тому +1

    Is this a jojo reference

  • @elliot2024
    @elliot2024 3 роки тому +1

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

  • @Lol-yf5td
    @Lol-yf5td Рік тому

    Does it work for steamvr?

  • @Lushsf
    @Lushsf Рік тому

    How is your hand invisible?

  • @xezienstudios
    @xezienstudios 2 роки тому

    GetButton doesn't work with the new input system

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

  • @Flowshow88
    @Flowshow88 2 роки тому

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

  • @keelanbowker-obrien2222
    @keelanbowker-obrien2222 3 роки тому +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 3 роки тому

      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 3 роки тому

      @@MrVic-qu9qh yup, this.

    • @MrVic-qu9qh
      @MrVic-qu9qh 3 роки тому

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

  • @connorwilson-long1336
    @connorwilson-long1336 3 роки тому +1

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

    • @fakefaker700
      @fakefaker700 3 роки тому

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

  • @FC12CGaming
    @FC12CGaming 3 роки тому

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

  • @exil_s4247
    @exil_s4247 2 роки тому

    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

  • @Dem0VR
    @Dem0VR Рік тому

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

  • @cazforshort
    @cazforshort 2 роки тому

    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.

  • @AmaroLoops
    @AmaroLoops 3 роки тому

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

  • @Inuitman
    @Inuitman 3 роки тому

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

  • @WeaselWatches
    @WeaselWatches 3 роки тому

    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?

  • @rXdanep
    @rXdanep 2 роки тому

    it says parameter fire does not exist
    what do i do

  • @daphnedigi3599
    @daphnedigi3599 3 роки тому

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

  • @mrmarcus3899
    @mrmarcus3899 2 роки тому

    Does it work with index?

  • @joshbrooks2827
    @joshbrooks2827 3 роки тому

    Can anyone confirm if the handpresance script still works

  • @CicadasFly
    @CicadasFly 3 роки тому +1

    Yes yes yes yes yes yes

  • @thegamingcoder4789
    @thegamingcoder4789 2 роки тому

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

  • @SentientAsWell
    @SentientAsWell Рік тому

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

    • @doubleaxe18
      @doubleaxe18 Рік тому

      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 Рік тому

      @@doubleaxe18 thx(:

  • @ZaCkOX900
    @ZaCkOX900 3 роки тому

    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 3 роки тому

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

  • @enemynotfunny7048
    @enemynotfunny7048 3 роки тому

    Does this work for oculus quest

  • @meeperhere
    @meeperhere 3 роки тому

    first vid where you use quest 2 :)

  • @Muempier
    @Muempier 3 роки тому

    with the xr grab can i use distance grab instead?

  • @randompathmain1575
    @randompathmain1575 2 роки тому

    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 2 роки тому

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

  • @geri4367
    @geri4367 3 роки тому

    Some recoil would be nice too :D

  • @AriAmpz
    @AriAmpz Рік тому

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

  • @RagnarGaming2801
    @RagnarGaming2801 3 роки тому

    hi man great work, but how to add recoil ?

    • @nubcake14
      @nubcake14 3 роки тому

      (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

  • @levioliveiradosreis1084
    @levioliveiradosreis1084 3 роки тому

    48th

  • @Doofles
    @Doofles 3 роки тому

    gun has no recoil?

  • @ТимурМ-ы7э
    @ТимурМ-ы7э 3 роки тому

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

  • @joshbrooks2827
    @joshbrooks2827 3 роки тому

    Nice

  • @eeroojanm98
    @eeroojanm98 3 роки тому

    How can you delete the hand when holding a gun?

    • @nubcake14
      @nubcake14 3 роки тому

      (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

  • @p00t0typ3
    @p00t0typ3 3 роки тому

    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

  • @ruffvr5932
    @ruffvr5932 2 роки тому

    WHY DOES THE GUN FALL THROUGH THE CUBE

    • @BlackDev
      @BlackDev 2 роки тому

      floor collision maybe

  • @maxwhite5988
    @maxwhite5988 3 роки тому +1

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

    • @ValemVR
      @ValemVR  3 роки тому +4

      What was the issue? :o

    • @maxwhite5988
      @maxwhite5988 3 роки тому +1

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

    • @maxwhite5988
      @maxwhite5988 3 роки тому +1

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

  • @PommeVerte47
    @PommeVerte47 3 роки тому +1

    Is he French?

  • @nace6849
    @nace6849 3 роки тому +2

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

  • @cinaryc9830
    @cinaryc9830 3 роки тому

    Great

  • @TylerS_4589
    @TylerS_4589 3 роки тому

    second :)

  • @VoidKeeperNull
    @VoidKeeperNull 3 роки тому

    18th

  • @Henry_c1
    @Henry_c1 3 роки тому

    Yessss

  • @SupremeRedFireTiktok
    @SupremeRedFireTiktok Місяць тому

    THANK YOU NOW I CAN MAKE MY BACKROOMS GAME