Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        agent           = GetComponent <NavMeshAgent>();
        detectionSphere = GetComponentInChildren <DetectionSphere>();
        Debug.Log(patrolRoute.Count);

        enemyAnim = GetComponent <Animator>();

        visitedWaypoints = new List <bool>();

        currentWaypoint = patrolRoute[0];

        reverse = false;

        patrol = true;

        // assign a default value of false for each waypoint in the patrol route
        for (int i = 0; i < patrolRoute.Count; i++)
        {
            visitedWaypoints.Add(false);
        }
    }
Beispiel #2
0
    private void Awake()
    {
        _navComponent    = GetComponent <NavComponent>();
        _detectionSphere = GetComponent <DetectionSphere>();
        _boxCollider     = GetComponentInParent <BoxCollider>();
        _healthComp      = GetComponentInParent <HealthComponent>();

        damageAmount = 10;

        if (!_navComponent)
        {
            Debug.Log("Failed to get Nav Component " + gameObject.name.ToString() + ", creating one now");
            _navComponent = gameObject.AddComponent <NavComponent>();
        }

        if (!_detectionSphere)
        {
            Debug.Log("Failed to get DetectionSphere on " + gameObject.name.ToString() + ", creating one now");
            _detectionSphere = gameObject.AddComponent <DetectionSphere>();
        }

        if (!_boxCollider)
        {
            Debug.LogError("Failed to get BoxCollider on " + gameObject.name.ToString() + ", creating one now");
            _boxCollider = gameObject.AddComponent <BoxCollider>();
        }

        if (!_healthComp)
        {
            Debug.LogError("Failed to get Health Component on" + gameObject.name.ToString() + " creating one now");
            _healthComp = gameObject.AddComponent <HealthComponent>();
        }

        _boxDefaultSize = _boxCollider.size;
        _boxAttackSize  = new Vector3(0.05f, 0.05f, 1f);
    }