I have a 3D model of a house, and I want an autonomous robot to move from 1 object in this house to the next one. I have it moving to the first, but it won't move to the second one. This is my code:
using UnityEngine;
using System.Collections;
public class MoveTo : MonoBehaviour {
public Transform[] goals;
void Start () {
NavMeshAgent agent = GetComponent<NavMeshAgent> ();
agent.destination = goals[0].position;
if (agent.transform.position == goals[0].position) {
agent.destination = goals[1].position;
}
}
}
I'm a complete beginner in code, please keep that in mind :)