示例#1
0
    void Awake()
    {
        //ObstaclesMask = LayerMask.GetMask("Obstacle");

        if (stateMachine == null)
        {
            stateMachine = GetComponent <EnnemyStateMachine>();
        }
        if (steeringBehavior == null)
        {
            steeringBehavior = GetComponent <SteeringBehavior>();
        }
        if (Fov == null)
        {
            Fov = GetComponent <FieldOfView>();
        }

        renderer  = GetComponentInChildren <SkinnedMeshRenderer>();
        materials = renderer?.materials;

        soundController = GetComponent <EnnemySoundController>();
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        gamecontrolleur = FindObjectOfType <gamecontrolleur>();
        stateMachine    = new EnnemyStateMachine();

        GameObject goPlayer = GameObject.FindGameObjectWithTag("Player");

        if (goPlayer != null)
        {
            player = goPlayer.GetComponent <Player>();
        }

        if (player == null)
        {
            Debug.LogError("ERROR : no player ref in Ennemy");
        }

        //Init Nav Mesh Agent
        nodes        = PathFinding.GetComponentsInChildren <PathFindingNode> ();
        navMeshAgent = GetComponent <NavMeshAgent> ();
        SetNavMeshTarget();
        Debug.Log("Number of Nodes: " + nodes.Length);
    }