So i was making a simple car System, and for the most part it works great (I havnt done parenting the player to the car yet) but you could click f and enter, BUT How do i make the code know When IM In the car, so when im in the car the ExitUI will appear
#pragma strict
var Player : GameObject;
var Car : GameObject;
var EnterUI : GameObject;
var ExitUI : GameObject;
var Enter;
var IsInCar
function Start () {
if (Car.activeInHierarchy(true))
{
IsInCar = true;
}
}
function Update ()
{
if(Enter == true && Input.GetKeyDown (KeyCode.F))
{
Player.SetActive (false);
Car.SetActive (true);
}
if(Car.activeSelf (true) && Input.GetKeyDown (KeyCode.F))
{
ExitUI.SetActive (true);
Player.SetActive (true);
Car.SetActive (false);
}
}
function OnTriggerEnter (other : Collider)
{
Enter = true;
EnterUI.SetActive (true);
}
function OnTriggerExit (other : Collider)
{
EnterUI.SetActive (false);
}
Errors
Assets/MyScripts/EnterCar.js(17,24): BCE0077: It is not possible to invoke an expression of type ‘boolean’.