I have a large ship, with this code attached →
var Waypoints : Transform[];
var currentWaypoint : int;
function Update () {
transform.parent.GetComponent("SmoothLookAt").target = Waypoints[currentWaypoint];
}
function OnTriggerEnter (collisionInfo : Collider) {
if(collisionInfo.gameObject.tag == "BomberWaypoint"){
currentWaypoint += 1;
}
if(currentWaypoint > Waypoints.length - 1){
currentWaypoint = 0;
}
}
@script AddComponentMenu("AI Scripts/Bomber AI");
This code works just fine, until it gets hit with a laser or missile. The colliders of both the waypoints and the ship are overlapping, that is very apparent. Once it is hit, it starts circling around currentWaypoint even after they’ve touched.
So what am I doing wrong here? I can’t have it start circling waypoints just because it got hit by a laser…