Hello! I using this script:
var Car :Transform;
var Player :Transform;
var exitPoint :Transform;
var doorTriggerLeft :Transform;
var PlayerCamera :Camera;
var CarCamera :Camera;
var isPlayerVisible :boolean;
function Update () {
if(Input.GetButtonDown("Fire2")&& isPlayerVisible){
Player.gameObject.SetActiveRecursively(false);
Player.gameObject.active = false;
Player.parent = exitPoint.transform;
Player.transform.localPosition = Vector3(-1.5,0,0);
exitPoint.parent = Car.transform;
exitPoint.localPosition = Vector3(-3,0,0);
// GameObject.Find("Car").GetComponent("Car").enabled = true;
// GameObject.Find("Car").GetComponent("SoundController").enabled = true;
GameObject.Find("Charger").GetComponent("CarController").enabled = true;
PlayerCamera.enabled = false;
CarCamera.enabled = true;
}
else{
if(Input.GetKeyUp("e")){
Player.gameObject.SetActiveRecursively(true);
Player.gameObject.active = true;
Player.transform.parent = null;
exitPoint.parent = doorTriggerLeft.transform;
//exitPoint.parent = Car.transform;
// GameObject.Find("Car").GetComponent("Car").enabled = false;
// GameObject.Find("Car").GetComponent("SoundController").enabled = false;
GameObject.Find("Charger").GetComponent("CarController").enabled = false;
//GameObject.FindGameObjectWithTag("sentryGun").enabled = true;
PlayerCamera.enabled = true;
CarCamera.enabled = false;
}
}
}
function OnTriggerEnter(Player : Collider){
isPlayerVisible = true;
}
function OnTriggerExit(Player : Collider){
isPlayerVisible = false;
}
Everything works fine only the exit. When i get in to the car then the exit point cordinates change. Can somebody help me?