Skip to main content
Up and Coming
March 16, 2016

Camera movement as Horizontal and Vertical inputs

I would like to use the camera movements as the "Horizontal" and "Vertical" inputs in Unity. This is what i wrote so far but no success, any help would be great!
using UnityEngine;
using System.Collections;

public class CamMoving : MonoBehaviour {



void Update ()
{

float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");



Camera.main.ScreenToWorldPoint(new Vector3 (moveHorizontal, moveVertical, 0));
}
}
    This topic has been closed for replies.

    3 replies

    Inspiring
    March 16, 2016
    That code doesn't make any sense to me.

    Can you maybe try to explain what your end goal is? There might be another way.
    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
    octaspaceAuthor
    Up and Coming
    March 16, 2016
    Still a beginner here but my motivation to get better in c# is very strong! :P So i got this first person shooter package and I'm trying to use it for my vr project. Strangely the aiming of the guns is not connected with the camera view, so you can just aim with the mouse or assign it to a Vertical or Horizontal value for like an gamepad. I'm trying to figure out for days how I can get the aiming with the camera view to work which is better for vr. Maybe you have an idea how I can solve that, thx!
    New Participant
    September 9, 2016
    It sounds like you want to use head tracking as input.  Unity's Input object doesn't provide that.   You will need to use OVRInput.   Read the documentation on this site about how to get set up (if you don't already have OVRInput in your project) and for details on how to use it.