Im making an NPC wandering system and have baked the navmesh and all but i want to know how i can get the childs transform (i have aan epty gameobject eith all the destinations)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Apple;
public class PersonBehaviour : MonoBehaviour
{
public GameObject destinationParent; // the empty game object
private int chosenDestination;
private GameObject destination;
private int destinationCount;
private Transform destinatonTransform;
void Start()
{
destinationParent = GameObject.Find("Destinations");
destinationCount = destinationParent.transform.childCount;
chosenDestination = Random.Range(0, destinationCount + 1);
//destinatonTransform = ???????
}
}
If the chosenDestination is the index that you are searching for this could be a solution.
destinationParent.transform.GetChild(chosenDestination).transform;