1
votes

I am building an A-Frame application and when in VR mode I can use the keyboard WASD to navigate and look up or down with movement to change camera height. The camera is facing forward except when I rotate my head in Oculus rift which works fine. In some Oculus apps such as home when you teleport you can rotate the thumbstick so that the direction you face changes after you teleport. Is there a way to change camera rotation with the keyboard in A-frame? I am using A-frame extras and my camera rig code is below. Thanks!

    <a-entity id="rig" movement-controls="fly: true; speed: 0.1" wasd-controls position="11 1.5 2" >
        <a-entity camera look-controls></a-entity>

    </a-entity>
1

1 Answers

1
votes

Add a rotation component to the id='rig' entity. Then you can make a new custom component ('overrotate'), and also add that to the id='rig' entity. Program overrotate to listen for keyboard input (whatever keys you like), and within that listener function, call the rotation component with a setAttribute(). Because you are now rotating the parent of the camera (the rig), you will still get your look-controls rotation of the camera, and also the override rotation for the rig, driven by keyboard input.