Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
octaspace's avatar
octaspace
Honored Guest
9 years ago

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));
}
}

3 Replies

Replies have been turned off for this discussion
  • 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.
  • 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!
  • 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.