Hello guys,
I am learning the basics of programming (Im a visual artist) and currently I am trying to make a demo with the Oculus Rift. I am trying to create a hands free movement in an environment just as this demo (Oculus Rift DK2 - Vision through 1 (Kira / Demo) - YouTube) Where at 0:30 seconds the person is looking at an object (or tag) and after a while the camera wil move to that location. This is what I am trying to recreate. I started with the Find Closest Enemy example, but I am not sure if I am on the right track.
If anything is unclear, let me know and I will try to clear things up.
Help would be appreciated!
/EDIT/ Here is the code that I have so far:
using UnityEngine;
using System.Collections;
// Find the name of the closest enemy
GameObject FindClosestEnemy() {
GameObject[] gos;
gos = GameObject.FindGameObjectsWithTag("Enemy");
GameObject closest = null;
float distance = Mathf.Infinity;
Vector3 position = transform.position;
foreach (GameObject go in gos) {
Vector3 diff = go.transform.position - position;
float curDistance = diff.sqrMagnitude;
if (curDistance < distance) {
closest = go;
distance = curDistance;
}
}
return closest;
}
}