All classes missing directive or assembly reference

Hi, I’m new to unity and game development in general and I am having an issue with installing the pathfinding project. Anytime I try to use any of the classes in the package inside a script, I get an error similar to the following:

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

I have read about a few other similar issues as mine but their solution didn’t work for me. I have tried deleting and reimporting the package multiple times. I made sure I followed the instructions in the getting started video exactly. I made sure I didn’t have any naming conflicts. I updated Visual Studios. None of these have worked for me unfortunately. I know there was a similar post that was made around 12 days before this but the issue for that person was due to a typo and I’m pretty sure I spelt “Path” correctly.

I’m using Unity 2019.3.0b7 if that makes a difference. Thank you to anyone who helps. As a complete newbie I’m quite lost and I really appreciate it.

sample code below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pathfinding; //using this directive still gives error

public class EnemyAI : MonoBehaviour
    public Transform target;

    public float speed;
    public float nextWayPointDistance = 0.5f;

    Path path;  //this would give a compiler error

That should work, odd.

Did you move project after install by any chance ?

If not, could you try again doing a complete reinstall. Import through the package importer. Don’t move it from another folder.

Thanks for replying. I don’t believe I did anything to my project after I installed. I’ll try your suggestion. Just to be clear, are there any specific steps that I need to take to uninstall the package before reinstalling? What I’ve been doing is deleting the Astarpathfindingproject folder from Visual Studio and then reimporting by double clicking the .unitypackage file from the zip.

Ye that sounds about right.
Could you verify that your project compiles before importing a*.

So if it still doesn’t work try it in an empty project.
If that also doesn’t work we can try clearing unity cache


Are you using assembly definition files in your project?

Okay so it works with an empty project so it must be about the assembly definition files that aron talked about.

EDIT: Sorry I also see a bunch of other .asmdef files for what I’m assuming are other builtin unity packages

Okay so I do see .asmdef files in my project:

I see a “GameAssemly.asmdef” file and a “AstarPathfindingProject.asmdef” file. I wasn’t sure what they were because I’m developing this project as part of a group and I didn’t set up the project. Here are the contents:

Your GameAssembly looks suspicious. You need to add a reference to the AstarPathfindingProject asmdef file in it. You can open it in the Unity inspector.

Does this look right? This is what I did:

1 Like

Okay that must be it! I can reference the classes in the package now. Thank you for all your help and patience. Sorry about the novice mistake!

1 Like