Unity's Survival Shooter tutorial with HTC Vive
Автор: Roland C
Загружено: 2016-12-31
Просмотров: 8631
Описание:
Update 2017-08-09: TheStoneFox did an official tutorial including teleporting, which is awesome. You should check it out. Here's the link:
• VRTK v3 - [Intermediate] Unity Survival Sh...
Original:
---------------------------
Quick convert of Unity's Survival Shooter tutorial to in Virtual Reality.
The whole learning and conversion process took around 2 hours of time. VRTK is awesome.
Also, the ZomBunny, ZomBear and Hellephant look great in VR, the video here can't show that :D
Used software:
VRTK (Virtual Reality ToolKit)
https://github.com/thestonefox/VRTK
Unity 5.5
https://unity3d.com/get-unity/download
Survival Shooter
https://www.assetstore.unity3d.com/en...
Steps for the conversion in case anyone wants to do it themselves:
import survival shooter
import steamvr
import vrtk
load "Level 01 5.x"
drag camerarig into scene
reset transform
disable main camera
create [VRTK] empty gameobject
-- drop VRTK_SDKManager script on it
-- select "Steam VR" for System SDK and all other SDK
-- click "Auto Populate Linked Objects"
attach empty gameobject named "RightController" to [VRTK]
add scripts:
-- VRTK_Controller_Events
-- VRTK_Controller_Actions
-- VRTK_Interact_Touch
-- VRTK_Interact_Grab
-- VRTK_Interact_Use
-- VRTK_Interact_Auto_Grab
assign RightController gameobject to VRTK_SDK_Manager's "Script Alias Right Controller"
create Gun.cs, code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;
public class Gun : VRTK_InteractableObject
{
protected override void Awake()
{
base.Awake();
}
public override void StartUsing(GameObject usingObject)
{
base.StartUsing(usingObject);
}
}
add Gun.cs to Gun gameobject and set:
is grabbable: true
valid drop: no drop
is usable: true
Gun gameobject:
add box collider to it and set:
Is Trigger: true
add VRTK_Child_Of_Controller_Grab_Attach
assign VRTK_Child_Of_Controller_Grab_Attach to Grabb Attach Mechanics (in that same gameobject, "Gun (Script)")
detach Gun from Player
-- reset transform
-- add empty gameobject GunSnapTransform
--- set Position 0.26 / 0.38 / 0.25 (note: needs proper adjustment, only for quick test)
set GunSnapTransform as Right Snap Handle in Gun gameobject
assign Gun gameobject to VRTK_Object_Auto_Grab -> Object To Grab
detach GunBarrelEnd from player and attach it to Gun
-- set position 0.281 / 0.41 / 0.972
-- set rotation 0.563 / 0 / 0
copy PlayerShooting.cs to PlayerShootingVR.cs (of course rename class name in code) and replace the script in GunBarrelEnd with it
-- add firing code
void Start()
{
VRTK_ControllerEvents events = VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerEvents>();
events.TriggerPressed += FireGun;
}
private void FireGun(object sender, ControllerInteractionEventArgs e)
{
Shoot();
}
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: