Assume I have a character that is game ready with animations.
I am wondering how to make this character walk to random locations when clicked on. Locations predetermined by markers.
Example: You have a room with “markers” in each corner.
Every time the character is clicked on he will walk to one of four corners inside the room at random.
GameObject[] markers;
void Start()
{
markers = GameObject.FindGameObjectsWithTag("marker");
//requires you to tag every marker as "marker"
}
void OnMouseDown() // Requires a collider on your character
{
//if you use NavMesh
GetComponent<NavMeshAgent>().destination = markers[Random.Range(0, markers.Length)].transform.position;
}
Of course it depends on which character movement system you use.