Skip to main content
Up and Coming
March 30, 2013

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?
    This topic has been closed for replies.

    2 replies

    Up and Coming
    March 30, 2013
    The 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.
    Participant
    April 4, 2013
    I 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.