You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

47 lines
1.2 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Moloch
{
public class WanderState : BaseState
{
private LocomotionSM m_SM;
private float m_MaxSpeed;
public WanderState(LocomotionSM machine) : base("Wander", machine) { m_SM = machine; }
public override void Enter()
{
base.Enter();
m_SM.m_NavMeshAgent.RandomWalk();
m_SM.m_NavMeshAgent.SetSpeed(Random.Range(0.5f, 2.5f));
m_SM.m_NavMeshAgent.SetAcceleration(Random.Range(0.5f, 1f));
}
public override void UpdateLogic()
{
base.UpdateLogic();
if (!m_SM.m_NavMeshAgent.HasReachedWaypoint())
{
m_SM.m_NavMeshAgent.StartMoving();
m_SM.m_Animator.SetFloat("Velocity", m_SM.m_NavMeshAgent.m_Agent.velocity.magnitude / 2.5f);
}
else
{
m_SM.SwitchState(m_SM.m_idleState);
}
}
public override void Exit()
{
base.Exit();
m_SM.m_Animator.SetFloat("Velocity", 0);
m_SM.m_NavMeshAgent.StopMoving();
}
}
}