public void CheckpointTrigger(GameObject cp, MyRaceAgent agent) { int index = checkpoints.IndexOf(cp); Vector3 nxtCheckpointPos = checkpoints[(index + 1) % NCheckpoints].transform.position; agent.CheckpointTrigger(nxtCheckpointPos, index); }
void OnTriggerEnter(Collider other) { // MyRaceAgent agent = other.gameObject.GetComponent<MyRaceAgent>(); MyRaceAgent agent = other.GetComponentInParent <MyRaceAgent>(); CheckpointManager manager = GetComponentInParent <CheckpointManager>(); manager.CheckpointTrigger(gameObject, agent); }