Okay so I have looked everywhere for the answer to my problem but found nothing, so I am guessing that it is something simple so I would like the community to look over my script for me.
Basically I am trying to make a GTA style game where the character (A First Person Controller) can collide with the car (Copy and Paste from the Car tutorial). The Character then presses “E” ad the debug log tells me what happened.
This is what I have so far.
var playerCamera : Camera;
var enterCar:boolean = false;
function OnCollisionEnter(collision : Collision){
if (collision.gameObject.tag == "vehicleCollision");
enterCar = true;
}
function OnCollisionExit(collision : Collision){
enterCar = false;
}
function Start(){
if(enterCar == false);
var vehicle = GameObject.FindGameObjectWithTag("Car");
yield WaitForSeconds (2);
print(Time.time);
vehicle.GetComponent(Car).enabled = false;
}
function Update(){
if (Input.GetButtonDown("Enter") && (enterCar == true))
var vehicle = GameObject.Find("Vehicle");
vehicle.GetComponent(Car).enabled = true;
playerCamera.enabled = false;
print("is in the car");
}