Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / NPC / Orc / Actions / ChaseTartet.cs
@Rackday Rackday on 3 Sep 676 bytes Minor Update
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MyCollections.AI.FinitStateMachine;

[CreateAssetMenu(menuName = "Finite State Machine/Action/ChaseTarget")]
public class ChaseTartet : Action
{ 
    public override void Run(FSM fsm)
    {
        Agent agent = fsm.Controller.Agent;
        EnemyNPCContoller controller = (EnemyNPCContoller)fsm.Controller;
        GameObject target = controller.AgentFOV.GetTarget();

        if (agent != null)
        {
            if (target != null)
            {
                agent.SetDestination(target.transform.position);
                agent.agentStop = false;
            }
        }
    }
}