Equivalent for Mouse.Hit in VR?

Hello everyone! I have this gun system I’m working on and I wish for it to be VR compatible. It currently uses a ray cast with Mouse.Hit to calculate where the raycast should draw and the bullet should hit. Currently, when a user goes into VR it shoots directly in the center of where their head is facing. How would I change the functionality of the gun to make it raycast out of the right arm of the player? I’m just wondering if there is a built in function or I would need to manually do this.

2 Likes

I haven’t really done any VR stuff in Roblox, but the steps I would probably take though would be to start by getting a part to follow the players controller. Then you can just cast a ray from the controller position in the direction of its lookvector assuming its rotated the correct way relative to the hand. I kind of doubt there is already functionality past that considering the direction of the ray relative to the hand could vary widely depending on use case and can be handled well by other methods already so implementing it directly wouldn’t have much merit as far as I can tell. Though I haven’t really even looked at any documentation for VR on this platform.

Mouse.Hit makes a raycast, of course. When it comes to VR, it sends the raycast from the right hand (or the right controller) without any advanced code. I just discovered this today.

edit: also sorry for being late (ahem 3 years)