using UnityEngine;
using System.Collections;
public class MyAK : MonoBehaviour {
public Transform firePos;
public GameObject fire;
SteamVR_TrackedObject vrTobj;
SteamVR_Controller.Device device;
// Use this for initialization
void Start () {
vrTobj = GetComponent<SteamVR_TrackedObject>();
device = SteamVR_Controller.Input((int)vrTobj.index);
}
// Update is called once per frame
void Update () {
if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
{
GameObject go = GameObject.Instantiate(fire) as GameObject;
go.transform.position = firePos.position;
go.transform.rotation = firePos.rotation;
RaycastHit hit;
if (Physics .Raycast (firePos .transform .position ,firePos .transform .forward ,out hit ))
{
Debug.DrawLine(firePos.transform.position, hit.point, Color.red);
if (hit .collider !=null )
{
Debug.Log(hit.collider.name);
}
}
}
}
}
SteamVR按键的简单操作
最新推荐文章于 2023-04-12 11:58:30 发布