使用vrtk进行手柄trigger按键交互,在VRSimulator中有反应能进行交互,但是picoVR不能进行交互是什么原因呢?
以下是我使用vrtk进行交互的代码
private VRTK_ControllerEvents controllerEvents;
private RaycastHit hit;
controllerEvents = GetComponent<VRTK_ControllerEvents>();
private void Update()
{
Vector3 rayOrigin = transform.position; // 获取射线起点和方向
Vector3 rayDirection =transform.forward;
if (controllerEvents != null && controllerEvents.triggerPressed)
{
Debug.Log("Trigger按下!");
// 创建射线
Ray ray = new Ray(rayOrigin, rayDirection);
if (Physics.Raycast(ray, out hit))
{
// 计算纹理坐标
int x = (int)(hit.textureCoord.x * rt.width);
int y = (int)((1 - hit.textureCoord.y) * rt.height);
Draw(x, y);
}
}
}