Basicly, i’ve got a script working so far that when i get near my game object a GUITexture will appear and the camera look locks to make it easier to click the button…
however if i regret and just leave the area, the GUITexture will dissapear as it should however the camera remains locked…
heres the code i have so far.
#pragma strict
var Entrance : Transform;
var guitexture : GUITexture;
function Start(){
}
function Update () {
var dist : float = Vector3.Distance(Entrance.position, transform.position);
if(dist<10)
{
guitexture.enabled = true;
Screen.lockCursor = false;
var firstPersonControllerCamera = gameObject.Find("Player").GetComponent(MouseLook);
var mainCamera = gameObject.Find("Main Camera").GetComponent(MouseLook);
firstPersonControllerCamera.enabled = false;
mainCamera.enabled = false;
}
else{
guitexture.enabled = false;
Screen.lockCursor = true;
firstPersonControllerCamera.enabled = true;
mainCamera.enabled = true;
}
}