Forum Discussion
Anton
13 years agoHonored Guest
Cursor Locking for First Person Games
Hi all,
As I've been playing around with integrating the OVRSDK into my first project, I ran into the situation that OnMouseDown/Up/Etc. are now fairly useless, as the cursor is in-between the two camera views, so it reporting the cursor position in a very un-intuitive/useless position. This ends up being a bit of a problem for almost anything using a cursor, as instead of using native functions, we're likely going to have to scratch-build an alternate solution (here's for hoping someone slams together an asset-store release for this quickly). From playing TF2 in vr mode, it seems they actually duplicate everything in both views, including the actual cursor itself.
Anyone have any quick hackee ideas for a generic cursor implementation?
As I've been playing around with integrating the OVRSDK into my first project, I ran into the situation that OnMouseDown/Up/Etc. are now fairly useless, as the cursor is in-between the two camera views, so it reporting the cursor position in a very un-intuitive/useless position. This ends up being a bit of a problem for almost anything using a cursor, as instead of using native functions, we're likely going to have to scratch-build an alternate solution (here's for hoping someone slams together an asset-store release for this quickly). From playing TF2 in vr mode, it seems they actually duplicate everything in both views, including the actual cursor itself.
Anyone have any quick hackee ideas for a generic cursor implementation?
2 Replies
Replies have been turned off for this discussion
- owenwpExpert ProtegeThe simplest way is to do a raycast into the scene from the camera position along the view direction and draw a screen oriented sprite object at the hit point as your cursor. You can have relative mouse movement shift the direction of that raycast as one possibility, or just lock it to the head orientation. Calling transform.forward on the head object will give you a vector pointing straight ahead, or you can use transform.localToWorldMatrix.MultiplyVector on a vector that you construct from mouse movement.
- wccrawfordHonored GuestI think true 3D needs a truly 3D targeting mechanism. The reticle worked fine in 2D, but just doesn't work well in 3D. Actual ironsights is one way. Laser targeting (paint a laser target on the thing aimed at in each camera) is another.
To determine what is being targeted, I'd raycast from the head (between the cameras) in the direction the cameras are looking.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 10 years ago
- 10 months ago