using UnityEngine;
using System.Collections;
using System;
public class Player : MonoBehaviour {
public static Player instance;//静态公有字段
public Transform _rightHand;//右手位置
public SteamVR_TrackedObject _rightTrackedObj;//VR脚本组件
public LineRenderer _rightLineR;//右手线性着色器
public Transform _rightModel;//右手手柄控制器的位置
public Ray _rightRay { get { return new Ray(_rightModel.position, _rightModel.forward); } }//一条从右手手柄发出的射线,指向正前方
public RaycastHit _rightHit;//右手射线检测体
public Transform _leftHand;//左手位置
public SteamVR_TrackedObject _leftTrackedObj;//左手VR脚本组件
public LineRenderer _leftLineR;//左手线性着色器
public Transform _leftModel;//左手手柄位置
public Ray _leftRay { get { return new Ray(_leftModel.position,_leftModel.forward); } }//左手射线,指向正前方
public RaycastHit _leftHit;//左手射线检测体
public Transform _footTex;//脚丫图片位置
public SteamVR_Controller.Device rightDevice;//右手设备控制器
public SteamVR_Controller.Device leftDevice;//左手设备控制
public float lastAngle;//最后的角度
public float currentAngle;//当前的角度
public Quaternion initQ;//初始四元数
public Quaternion resultQ;//结果四元数
public Skybox skyBox;//天空盒
void Awake()
{
instance = this;
_rightHand = this.transform.Find("RightHand");
_rightTrackedObj = _rightHand.GetComponent<SteamVR_TrackedObject>();
_rightLineR = _rightHand.GetComponent<LineRenderer>();
_rightModel = _rightHand.Find("Model");//
_leftHand = this.transform.Find("LeftHand");
_leftTrackedObj = _leftHand.GetComponent<SteamVR_TrackedObject>();
_leftLineR = _leftHand.GetComponent<LineRenderer>();
_leftModel = _leftHand.Find("Model");
_footTex = GameObject.Find("foot").transform;
initQ = _footTex.rotation;
skyBox = this.transform.Find("Camera (head)/Camera (eye)").GetComponent<Skybox>();
InitLeft();
}
void Update()
{
PlayerInput();
}
public void
Unity3D-VR人物瞬移、脚丫旋转判定、高光、开关灯、门、电视
最新推荐文章于 2023-11-09 22:53:06 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)