Just wondering how I can do a simple check to see if my player is moving? I am working on adding animations onto my character and beginning with walking animations. I am not certain of the best way to impliment walking animations, but it seems like using the mechanim system is the best way. If you knoe amy good tutorials as well I’m happy to check it out haha
Hi
You can check the velocity of the agent.
ai.velocity;
See https://www.arongranberg.com/astar/docs/iastarai.html#velocity
Perfect! Thank you so much!
Hm, it seems to be not quite as plug and play as I was hoping. I’ll show you the code I am working with and hopefully there is a simple solution.
[CODE]NavMeshAgent agent;
Animator animator;
void Start ()
{
agent = GetComponent ();
animator = GetComponent ()
}
void Update
{
float speedPercent = agent.velocity.magnitude / agent.speed;
animator.SetFloat (“speedPercent”, speedPercent);
}[/CODE]
I am looling to simply switch the NavMeshAgent for the Seeker. The Start and initial variables are pretty easy to do, but the Update function I am having a lityle trouble with where to insert “ai.velocity”
Hi
That code seems to use Unity’s navigation system. Your ‘agent’ field should have the type IAstarAI (an interface which all movement scripts in this package implement, the actual classes are AIPath/RichAI/AILerp).
agent = GetComponent<IAstarAI>(); // Finds any attached AIPath/RichAI/AILerp component
float speedPercent = agent.velocity.magnitude / agent.maxSpeed;
I knew it would be something simple like that haha. Thanks for the help! Love the astar asset!