I’m making a 3D platformer for the Rift and I don’t want the player to control the camera so I want to it move to different positions depending on where you are in the level. In the code above I have the camera moveable by pressing the G and H keys and it works but ultimately I want to place triggers around the level that move the camera where it needs to be and I have no idea why it’s not working but going through the trigger does nothing. I’ve used info : Collider and other : Collider (I don’t know what the difference is) and neither work. Any suggestions? And, is this even the best way to do this?
Thanks
#pragma strict
var target : Transform;
public var distance = 10;
public var lift = 1.5;
public var unknown = 0;
var camPosition = Vector3(unknown, lift, distance);
var camSide = true;
function Update () {
if (camSide){
transform.position = target.position +Vector3(unknown, lift, distance);
}
if (!camSide) {
transform.position = target.position +Vector3(distance, lift, unknown);
}
if (Input.GetKey(KeyCode.G)){
camSide = false;
Debug.Log("camswitch");
}else if (Input.GetKey(KeyCode.H)){
camSide = true;
Debug.Log("camswitch");
}
transform.LookAt (target);
}
function OnTriggerEnter(other : Collider){
if (other.tag == "cam1"){
camSide = false;
}
}