Support Forum

Can't add script error when inheriting GraphUpdateObject

As seen here: https://arongranberg.com/astar/documentation/4_2_15_671e80cf/graphupdates.html on the section The Graph Update Object, I’m trying to recreate MyGUO script from the example which inherits from Graph Update Object.

I’ve tried recreating the script with unique names, copy-pasting code on the example, and moving the script around the project folder, but whenever a script inherits from Graph Update Object, it cannot be attached to a game object. When I try to do so, it returns a mesasge saying that “Can’t add script: The script don’t inherit a native class that can manage a script”.

I’m using 4.3.43 version, and the documentation is on 4.2.15 version, so I wonder if inheriting from Graph Update Object is outdated.

Hi

The GraphUpdateObject is not a monobehavior and you should not try to attach it to a GameObject.
You use a GraphUpdateObject purely through code like this:

// using Pathfinding; //At top of script

// As an example, use the bounding box from the attached collider
Bounds bounds = GetComponent<Collider>().bounds;
var guo = new GraphUpdateObject(bounds);

// Set some settings
guo.updatePhysics = true;
AstarPath.active.UpdateGraphs(guo);