Hello,
I am having an issue with detecting only one collision. I have a game where there is a standard asset FPS controller and two cars. By the door there is a trigger, and when my character is inside the collider box I can press ‘e’ and he will get in the car.
When you get in the car, a car driving script is activated so I can control the car.
If I park two cars right next to each other and stand in-between them, my character gets in both of the cars. And both scripts are activated and I can drive both the cars.
if (playerInRange == true){
if (Input.GetKeyDown("e")){
if (playerInVehicle == false){
playerInVehicle = true;
Char.active = false;
Char.transform.parent = gameObject.transform;
//Car.GetComponent(AudioSource).enabled = true;
Car.GetComponent(CarEngine).enabled = true;
//Cam.GetComponent(MouseOrbit).target = CamTarget2;
// Disable mouse cam, and enable car cam.
CarCam.GetComponent(CarCamera).car = CamTarget2;
CarCam.GetComponent(CarCamera).enabled = true;
}
else if (playerInVehicle == true){
playerInVehicle = false;
Car.GetComponent(CarEngine).enabled = false;
Char.active = true;
Char.transform.parent = null;
Char.transform.position.y += 0.04;
Char.transform.rotation.x = 0.00;
Char.transform.rotation.y = Car.transform.rotation.y;
Char.transform.rotation.z = 0.00;
}
}
}
How can I make it so that only one script gets activated, and not both??