Realistic Gun in VR - Part 1
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
First :)
I don't have the Xr grab intractable component can you help?
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);
}
}
@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
nice
@@GoldFishNoMore you have to go to package manger press the plus type com.unity.xr.interaction.toolkit
was trying to make a vr gun with realistic loading like this myself. lets just say...im glad this new tutorial came out
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 :)
I have been learning so much from these videos and have a few prototypes up and running on the Quest. Thank you, Valem!
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.
No, it's not Unreal, its Unity! lol
i have been waiting for a video like this for so long
This is exactly what ive been looking for
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
Thanks! This is some good insight into VR.
7:33 - No truer words have ever been said!😂 Love your work, Valem
yeah i loved that damn line.
Actually this is the best CZcams Channel
this enabled me to use my first code in vr man thanks heaps bro
My favorite gun out there, -Valem 2020
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.
Thank you!
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.
Thank you for making this! I needed this so much :)
without you Valem, i would be oh so lost
Awesome, thank you
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!)
"A programmer makes the code. But a good programmer takes the code" Valem - Oct 29, 2020
Will you be making an updated full series on VR development? Alot of stuff I feel is outdated from the original set of tutorials
Какой же ты молодец!!!!!!!! Respect
Hi Valem, it would be really cool if you could do something on physics based vr, something like a boneworks system.
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.
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?
does this also work for valve index, working with unity's xr plugin (cause u did a tutorial for steamvr before )??
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
All the textures of the prefabs are appearing pink, but it hasn't before when i have used this package. anybody help?
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
hi as a beginner developer should i buy rift s or quest?
Everytime I hear him say "Nokobot" I think he's saying knucklebutt
im planning on using this asset for my game, the asset isn't copyrighted is it?
Some recoil would be nice too :D
Can you use the XR script to make it playable in Oculus quest?
with the xr grab can i use distance grab instead?
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
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.
They are further out and to the left some. I've tried everything I know to fix it and it dosent work
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
It should. If you followed this tutorial, the ik tutorial and custom pose tutorial this should work perfect, best of luck in your game!
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?
I am developing the game but how can i test it without the vr glasses?
first vid where you use quest 2 :)
Hey m8 can you make a updated version of this for the tutorials channal
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.
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.
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 :(
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.
@@MrVic-qu9qh yup, this.
@@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.
Can you give me a link to XR tutorial?
Are you reincarnation of Brackeys? 🤔
Yes hs is
Yes yes yes yes yes yes
Is it possible for my to use my own model and create this gun?
Is there any way to add haptic feedback when you shoot the gun.
Yes, on the XR Direct Interactor, usually on each controller, there are options for haptics.
Can I use the script for a other model
valem: you might be mad because I didn’t create my own script
Animators & 3D modelers:...
Btw I love ur vidds
Its ok
Does it work with index?
I can't open the simple shoot script, does anyone has the same issue? Or does someone have a solution?
How is your hand invisible?
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);
does this go under the code underneath that comment?
Is it Oculus quest 2 ?
GetButton doesn't work with the new input system
Can anyone confirm if the handpresance script still works
Does this work for oculus quest
it says parameter fire does not exist
what do i do
What does the code say after tempCasing.GetComponent().AddExplosionForce(Random.Range(ejectPower * 0.7f, ejectPower), (casingExitLocation.position - casingExitLocation.right
HELP
Anyone have an answer to this I'm in the same boat
@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);"
gun has no recoil?
Does it work for steamvr?
hi man great work, but how to add recoil ?
(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
Nice
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.
Looking forward to seeing you add your skills for realistic guns into your Unity Tutorials you’ve already made!
How can you delete the hand when holding a gun?
(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
my gun is complety purple
anyone know why
Is this a jojo reference
it doesnt show pull tigger as a function
I have the same problem
Great
for some reason the gun has been falling through the floor do you know why?
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
@@doubleaxe18 thx(:
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???
WHY DOES THE GUN FALL THROUGH THE CUBE
floor collision maybe
Yessss
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
MAKE THE SAME TUTORIAL WITH OVRPLAYER OCULUS
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.
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 :)
Thank you so much for this tutorial, I tried on my own and It didn’t work at all.
What was the issue? :o
I am brand new at learning code was the issue honestly.
I wrote it the wrong way, your tutorial worked it was my attempts before this that didn’t work
sexyy, also 100th comment
48th
rEaLiStIc ShOoTiNg
Recoil be like: im bouta end this mans whole career
second :)
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);
}
}"
Is he French?
Does it matter?
@@AtomsForFuel I am French too so I guess no
belgium
18th