Creating a VR Weapon Raycast

Hello. Probably a simple question

I’m trying to make an VR FPS where the weapon stays attached to the motion controller. I’m trying to get firing to work using raycast, but I can’t seem to get it working. The raycast just either goes upwards or into random directions.

The raycast starts at the muzzle socket of the weapon.

How do you perform a ray cast in VR?

Thanks in advanced.

ray cast in VR is no different than standard ray cast, If you are using the template FPS gun you should be able to do it like this:

What I’m doing here is starting the ray cast at Muzzle socket and setting the end equals to the own start plus forward direction for a 100cm distance. And I set the object types to WorldDynamic, if you wish to hit other objects please remember to add that into the array.

Note that I’m using the Right Vector since the template gun has the Y axis as forward, if your gun has the X axis as forward use the GetForwardVector node and so on…

That did the trick. Thank you!