Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        GameObject tempObj = Instantiate(pedestrainObjs[Random.Range(0, pedestrainObjs.Length)], transform.position, Quaternion.identity) as GameObject;

        tempObj.name             = "PedestrainModel";
        tempObj.transform.parent = transform;
        tempObj.GetComponent <Animator>().runtimeAnimatorController = walkAnimationControllers[Random.Range(0, walkAnimationControllers.Length)];

        agent = GetComponent <UnityEngine.AI.NavMeshAgent>();
        agent.SetDestination(targetPos);

        agent.speed = Random.Range(0.8f, 1.8f);
        agent.GetComponentInChildren <Animator>().speed = agent.speed * 0.8f;

        if (Random.value < dirChangeProbablility)
        {
            changeDir     = true;
            dirChangeTime = Time.timeSinceLevelLoad + dirChangeBaseTime + Random.value * dirChangeTimeWindow;
        }
        else
        {
            changeDir = false;
        }
    }