Skip to main content
Up and Coming
September 25, 2013

[Solved] OVRCameraController follow target?

EDIT: The problem was solved with the code snippet (top answer) http://answers.unity3d.com/questions/13033/how-to-determine-if-enemy-is-on-my-left-or-right-h.html

So I'm one of those people new to Unity and the Oculus.

I'm basically trying to recreate Valve's vr_moveaim_mod 3/4 right now in my game. http://media.steampowered.com/apps/valve/2013/Team_Fortress_in_VR_GDC.pdf (info on page 33)

I'm try to make it so when I move my cursor to the edge of the screen the OVRCameraController will make the cameras rotate to follow the target.

I have a cube that moves left/right/up/down across my screen and I want the cameras to follow that.

I am not using the OVRPlayerController, just the OVRCameraController and I tried setting the FollowOrientation to the target.

Any thoughts/advice on where to look? Thanks! :)
    This topic has been closed for replies.

    6 replies

    Inspiring
    September 25, 2013
    If you try the Tuscany demo, when you press C a crosshair will appear that works similar to what you want. Maybe take a look at the code and see if you can pull out what you need.
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    October 2, 2013
    i'm also working on something similar where i want to rotate the camera towards an object when that object reaches the screen edge. But i dont see how the code snipet in this:
    http://answers.unity3d.com/questions/13033/how-to-determine-if-enemy-is-on-my-left-or-right-h.html
    solves the problem...the problem i've been having is that i can effect the rotation of the OVRCameraController.
    DarkJamesAuthor
    Up and Coming
    October 2, 2013
    "saarwii" wrote:
    i'm also working on something similar where i want to rotate the camera towards an object when that object reaches the screen edge. But i dont see how the code snipet in this:
    http://answers.unity3d.com/questions/13033/how-to-determine-if-enemy-is-on-my-left-or-right-h.html
    solves the problem...the problem i've been having is that i can effect the rotation of the OVRCameraController.


    So what problem have you been having? You say you CAN rotate the OVRCameraController? Is this a bad thing for your problem?
    Seeing is believing
    Up and Coming
    October 25, 2013
    Sorry, should say, "can't effect". In the end i managed to solve it. dont kno if it's the best way but i did it when my object reaches a value i go in to the cameraplayercontroller script and exchange the Input.Getkey command

    if (---the cubes positions is bigger than a certain value---)
    YRotation -= rotateInfluence * 0.5f;
    if (--if the cubes position is smaller than a certain value----)
    YRotation += rotateInfluence * 0.5f;


    this is not the most elegant solution

    I would like to use the cameracontroller. But i dont know what i should use to rotate the camera. it would be nice to see how you solved it, and what values/commands you used to rotate the camera
    Inspiring
    October 25, 2013
    Can you explain exactly what it is you are trying to accomplish?
    AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV
    Up and Coming
    October 30, 2013
    "cybereality" wrote:
    Can you explain exactly what it is you are trying to accomplish?



    i always thought that using the mouse and keyboard or a gamepad a bit cluncky when controlling a first person character in the oculus. And a hydra is something that mayby isnt that common among people so i've been exploring alternetivs.

    What i'm experimenting with is using a touch device (in my case an HTC ONE android) to controll your character. Right now when im touching my phones screen an object appears in the 3d space. I can move that how ever i want in the X and Z axis and when i double tap the screen my character in game moves to that point. So it's basicly working like mouse marker. i've got this to work by having a android project loaded to my phone and a project with a server program running on the computer, then sending data about my fingers position on the screen via the Wi-fi.

    To my camera problem. Say im playing and move my marker to the left and follow with my head to look where the marker is, mybody is facing straight forward but my head is looking left. If i now decide to move my character there i get this weird feeling when my that im walking diagonaly, and change my head position to look forward it feels even more wrong. When you decide to walk somewhere you want your whole body facing the way you are going. So i want to rotate the character to the left in this case so the use have to compensate with moving their head right and then get an aligned head and body.

    i have some more diffrent smart phone/tablet related interactions with a VR world that i want to try out where i force the camera to move. So a nice way to move force move the camera would be nice.

    (sorry about the bad english)