0

我需要从控制器中拍摄元素,因此理想情况下,它们会朝着您可以看到的激光指针的方向移动,并随着控制器移动。

这就是我需要的:

GameObject controllerLaser;
controllerLaser = GameObject.Find("VRMain/GvrControllerPointer/Laser");

Debug.DrawRay(firingSource.transform.position, firingDirection * 50, Color.red);

我需要那个红色矢量像激光一样指向和移动。

4

1 回答 1

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);
于 2017-05-01T06:05:56.200 回答