如何获得指向激光方向的矢量?

how to get vector pointing in Laser direction?

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

这是我需要的:

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

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

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

我成功了..

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);