Ejemplo n.º 1
0
    // # --- End of variables --- #

    private void Start()
    {
        enemyAgent        = GetComponent <NavMeshAgent>();
        currentPatrolPath = GetComponent <EnemyCombatAI>().patrolPath;
        guardPosition     = transform.position;
        guardRotation     = transform.rotation;
    }
Ejemplo n.º 2
0
    void Start()
    {
        ///////// have to get Game Objects and patrol path manually now that spawner can spawn different enemy types ////////////////
        enemyPrefab = transform.parent.parent.gameObject;
        enemyPrefab.transform.rotation = transform.rotation;
        spritePlane = transform.GetChild(0).gameObject;
        patrolPath  = transform.parent.parent.transform.GetChild(1).GetComponent <EnemyPatrolPath>();


        patrolPathParent = GameObject.FindGameObjectWithTag("Patrol-Paths_Parent");                     // The patrol paths for all enemies actually get detached and reparented to a master parent in the scene (I cannot remember why)
        patrolPath.gameObject.transform.SetParent(patrolPathParent.transform);                          // so after finding the parent in the line above, it is then attached to it here


        playerTarget = GameObject.FindGameObjectWithTag("Player");                                      // Set the player as the enemy target
        pathLoop     = patrolPath.loop;                                                                 // if the path loops or not has to be derived from another object, so it's grabbed here
        state        = EnemyState.Patrolling;                                                           // Set initial STATE to PATROLLING
        //state = EnemyState.Idle;
        //state = EnemyState.Roaming;
        currentNodePosition            = patrolPath.pathNodes[currentNode].transform.position;          // set "current position" -> the nex path to move to as the first node in the node path position list
        enemyPrefab.transform.position = patrolPath.pathNodes[0].transform.position;
        speed = patrolSpeed;

        enemySpriteMaterial = spritePlane.GetComponent <Renderer>().material;
        enemySpriteMaterial.SetFloat("_AnimationNumber", 1);
        enemySpriteMaterial.SetFloat("_FrameOffset", 0);
        fakeTime = 0.0f;
    }
Ejemplo n.º 3
0
 private Vector3 GetCurrentWaypoint()
 {
     currentPatrolPath = GetComponent <EnemyCombatAI>().patrolPath;
     return(currentPatrolPath.GetWaypoint(currentWaypointIndex));
 }