-
Install NewtonVR by pressing "Enable SteamVR" in NVRPlayer prefab.
-
Inside NVRPlayer(camera rig), select both hands add "SteamVR_TrackedController component(script).
5)Now You need a gun with separate slider.
6)Add Rigidbody and NVRInteractableItem components to the gun.
-
Add all neccessary colliders for the all pistols parts, but do not add colliders on slider yet!
-
Create empty gameobject and name it "Relative Point". Set on on the Slider height.
-
Now make two child colliders inside the slider. First one name "Slider Collider", and second one make a bit bigger and name "Slider Trigger"
-
After that, to the "Slider trigger" add "Pistol Controller" component.
-
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.
Done! Pistol is ready!
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.
-
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. -
In animator controller you need to add 2 float parametrs: BoltRotate, BoltSlide.
-
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:
-
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.
That's how it's might look like:
So, That's it!
All contributions are welcome :)