Type error for AStartAI and Pathfinding

The type or namespace name ‘Pathfinding’ could not be found (are you missing a using directive or an assembly reference?)

The type or namespace name ‘AStarAI’ could not be found (are you missing a using directive or an assembly reference?)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pathfinding;

public class AStarAnimator : MonoBehaviour
{
AStarAI astar;
Animator _animator;
void Start()
{
astar = GetComponent();
_animator = GetComponent();
}

What specific component are you attempting to call? Do you have a gameobject on your tree holding the actual AStarPath script?
For example, you might be wanting to call the seeker component of the AStar, not astar itself.

If you haven’t already, I very highly recommend following the Brackey’s script for your setup, it is absolutely gold. He explains brilliantly. If you have already followed that sort of setup already, can you please elaborate much more thoroughly on your setup?

I’m trying to sync mechanim movement animation with the velocity of the agent. I read in another thread the X and Y coordinates’ velocity can be read from the AStarAI component, that’s why I was referencing it. If I’m wrong, can you please direct me as to where I can reference the agent’s velocity? Also, thank you for the Brackey’s info, I will look at it also.

As per the brackey tutorial, I created a secondary script for the movement function.
Keep in mind that the basic setup of AStar is just finding the path. What you choose to do with the path is up to you. You can use the path to set tiles (like a city builder making roads), or you can use the path to tell the rigidbody where to go.

In my own script, I find the target using AStar seeker script, then do a mover script that dictates “if it is to the left, apply force to the left”. The object with the force then has velocity (scaling over time as it is not an impulse). You can use update or physics update to tell the other script what the velocity is.

In my game, my goblin completes a walk cycle in 1 second. AStar doesnt factor in to that at all - the velocity is from the mover script, and the mover is told where to go via astar. So I tell the animator what the speed is via the mover - not the astar.

Now, I don’t know a lot about astar, maybe it CAN directly tell you the velocity. This is only the way I did it, and it works.

Ok thanks for this idea. Sounds like the mover script is what I need. I’m so used to Unity’s NavMeshAgent handling everything, it’s a bit confusing using A * now. I appreciate your help.

Brackey’s explanation helps immensely. He moved on to godot and the tutorial is ancient, but man is it well spoken and easy to follow.

Also, I’m a dumb, so if anyone else has a bigger brain, please chip in.

Yes I was bummed when I found out he changed sides. I have the tutorial pulled up now, hopefully in a few minutes I’ll have things working. Thanks again

Check your spelling. It’s IAstarAI.

1 Like

Thanks that was the issue.

@Rawr_Andres AstarWorking|266x357

I got it working! My animations and transitions are synced using the IAstarAI velocities. @Rawr_Andres @aron_granberg

Fantabulous! Like I said before, I’m just some dumb, doing my best :slight_smile:

1 Like