Hello, I am having a problem with my AI traffic vehicle buses. In the picture, the 2 buses are completly stopped, with neither of them moving. How do I prevent this?
AI trigger part of the script(not the whole thing):
function checkLightsAndCars() : System.Boolean {
var hit : RaycastHit;
var distance : float = 2;
if(Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), hit, distance)){
if(hit.collider.transform.name == "StopArea"){ //Did we hit the gameObject called "StopArea"
EngineTorque = 0;
inputTorque = 0;
FrontLeftWheel.brakeTorque = 1000;
FrontRightWheel.brakeTorque = 1000;
rigidbody.velocity = Vector3.zero;
TailLight.gameObject.active = true;
}
}
else { //We haven't hit anything that will stop us moving
EngineTorque = 100; //Return true so the car can move
FrontLeftWheel.brakeTorque = 0;
FrontRightWheel.brakeTorque = 0;
TailLight.gameObject.active = false;
}
var distance2 : float = 8;
if(Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), hit, distance2)){
if(hit.collider.transform.name == "AICar"){ //Did we hit the gameObject called "AmbientVehicle"
EngineTorque = 0;
FrontLeftWheel.brakeTorque = 10000;
FrontRightWheel.brakeTorque = 10000;
rigidbody.velocity = Vector3.zero;
TailLight.gameObject.active = true;
}
else { //We haven't hit anything that will stop us moving
EngineTorque = 110; //Return true so the car can move
FrontLeftWheel.brakeTorque = 0;
FrontRightWheel.brakeTorque = 0;
TailLight.gameObject.active = false;
}
}
}
Image: