我需要从控制器中射出元素,所以理想情况下它们会朝着你可以看到的激光指示器的方向移动并随控制器一起移动。
这就是我需要的:
GameObject controllerLaser;
controllerLaser = GameObject.Find("VRMain/GvrControllerPointer/Laser");
Debug.DrawRay(firingSource.transform.position, firingDirection * 50, Color.red);
我需要红色矢量指向和移动完全像激光。
答案 0 :(得分:0)
我设法做到了..
GameObject controllerLaser;
controllerLaser = GameObject.Find("VRMain/GvrControllerPointer/Laser");
//The Laser GameObject has the Reticle as its child, so you can make a vector
//that goes from the controller position to the reticle
firingDirection = controllerLaser.transform.GetChild(0).position - controller.transform.position;
//For firing the bullet (bonus)
bulletRB.velocity = firingDirection * bulletVelocity;
Debug.DrawRay(firingSource.transform.position, firingDirection * 50, Color.red);