Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.
/ weaponReloadVR Public archive

Weapons Reload Mechanics for VR | Unity3d ( NewtonVR & SteamVR)

License

Notifications You must be signed in to change notification settings

Oyshoboy/weaponReloadVR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

Showcase

showcase

How to use it ( PistolController.cs ).

  1. Download NVR and SteamVR assets from AssetStore.

  2. Then put on scene NVRPlayer Prefab ( camera rig ).
    Prefab

  3. Install NewtonVR by pressing "Enable SteamVR" in NVRPlayer prefab.
    install

  4. Inside NVRPlayer(camera rig), select both hands add "SteamVR_TrackedController component(script).
    install

5)Now You need a gun with separate slider.
gun

6)Add Rigidbody and NVRInteractableItem components to the gun.
gun

  1. Add all neccessary colliders for the all pistols parts, but do not add colliders on slider yet!
    gun

  2. Create empty gameobject and name it "Relative Point". Set on on the Slider height.
    gun

  3. Now make two child colliders inside the slider. First one name "Slider Collider", and second one make a bit bigger and name "Slider Trigger"
    gun

  4. "Slider trigger" set as trigger.
    gun

  5. After that, to the "Slider trigger" add "Pistol Controller" component.
    gun

  6. Finally set all neccessary variables:
    -12.1 Current Object Item - set your gun itself.
    -12.2 Relative Point - set your empty gameobject called "Relative point" which we created on the step 8.
    -12.3 This gun Slider - add guns Slider gameobject.
    gun

Done! Pistol is ready!

Sniper Bolt Controller (sniperBoltController.cs):

All procedure is 80% same as with pistol, but for bolt action we need more movements and different sequence. So to simplify it for now, I decided to make it using animations.

  1. You need to add animator controller to the slider (bolt), and record 3 animations: boltIdle, BoltRotate, boltSlide. Each animation is should be 1 frame length, cuz transition will be automatic.
    boltIdle - is just an idle animation. BoltRotate - is 55 degree rotate animation. boltSlide - is the Z axis move animation.

  2. In animator controller you need to add 2 float parametrs: BoltRotate, BoltSlide.
    gun

  3. Then add first blend tree and add 2 motions ( boltIdle and BoltRotate) and one another blendtree in "Motion" section. All blending should depend from "BoltRotate" parameter, and set threshold as on screenShot:
    gun

  4. In second blend tree add 2 motions: (BoltRotate and boltSlide(I have mistake in animation name - blotSlide :D)) and make them blend under "BoltSlide" parameter.
    gun

That's how it's might look like:
gun

So, That's it!
All contributions are welcome :)

About

Weapons Reload Mechanics for VR | Unity3d ( NewtonVR & SteamVR)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages