NPC 행동 변경
public void GuardWait()
{
var agent = stateMachine.npc.Agent;
if (!isWaiting)
{
waitTimer += Time.deltaTime;
moveTimer += Time.deltaTime;
if (moveTimer >= moveDelay)
{
agent.SetDestination(GetRandomPointInArea(stateMachine.npc.Area));
moveTimer = 0f;
}
bool isMoving = !agent.pathPending && agent.remainingDistance > agent.stoppingDistance;
if (isMoving) StartAnimation("Walk");
else StopAnimation("Walk");
if (waitTimer >= 3f)
{
if (stateMachine.npc is Guard guard)
{
agent.SetDestination(guard.GetWaitPosition().transform.position);
isWaiting = true;
waitTimer = 0f;
}
}
}
else // 대기중
{
if (!agent.pathPending && agent.remainingDistance <= agent.stoppingDistance)
{
StopAnimation("Walk");
cooldownTimer += Time.deltaTime;
if (cooldownTimer >= 5f)
{
isWaiting = false;
cooldownTimer = 0f;
waitTimer = 0f;
agent.SetDestination(GetRandomPointInArea(stateMachine.npc.Area));
}
}
}
}
처음부터 제대로 알려주지