A* Pathfinding Project

Issue with accessing my own scripts from AILerp


#1

Hey!

I was forced to update Unity to 2019.2.0f1 in order to meet the new Google Play requirements and doing so a new error occurred. Basically I have bots with AILerp and my own script attached to them, I’ve been using OnTargetReached () to access my own script to do certain things in the game;

OnTargetReached () {

gameObject.GetComponent(MyOwnScript)().MyOwnAction();

}

However now I can’t seem to access my other scripts from AILerp, for example in my own scripts if I type “Ga…” it automatically suggests my own GameManager script but when I do that in AILerp it doesn’t know what GameManager is.

I’ve been programming for few years now but I only use “regular” scripts where anything can be accessed from anywhere so I don’t have a clue what’s going on.

What change do I need to make so I could access my own scrips from AILerp again? Thanks! :slight_smile:


#2

Hi

The A* Pathfinding Project uses assembly definition files (https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html) which makes the pathfinding code lie in a separate dll file. If you really need to you can delete the .asmdef files in the package and everything should work, but I would recommend that you instead use a separate script and check the ai.reachedDestination property. That property is both much less error prone than the very old OnTargetReached method (which has a lot of quirks) and you will not have to modify the scripts again if whenever you upgrade the package.