I want to use an array for tags, I tried something like this:
if (col.tag == “pos[numbe]”) This did not work…
Is there any way to make this work, help will be appreciated.
public Transform[] pos;
public float timer;
public int numbe;
private NavMeshAgent navComponent;
// Use this for initialization
void Start()
{
navComponent = this.gameObject.GetComponent<NavMeshAgent>();
}
void Update()
{
//Selecting waypoint at random
timer-= Time.deltaTime;
if (timer<= 0f)
{
numbe = Random.Range(0, 4);
timer= 5;
}
navComponent.SetDestination(pos[numbe].position);
}
//Switching between way point upon collision
public void OnTriggerEnter(Collider col)
{
//Collision with waypoint 0
if (col.tag == "0")
{
Debug.Log("debug0");
}
//Collision with waypoint 1
if (col.tag == "1")
{
Debug.Log("debug1");
}
//Collision with waypoint 2
if (col.tag == "2")
{
Debug.Log("debug2");
}
}