Can I set penalty by Unity's Tag or Layer something like Unity's Nevmesh baking?


I’ve made different tags and layer for different meshes of the game environment. And resetting the A* tag by GUO take much time and not easy to update with the model changing. Is there a way like Unity’s Nevmesh baking to set penalty values by Gameobject or Mesh’s Layer or Tag?
I don’t know how to do that by A*'s GraphUpdateObject scripting cause it handles Nodes.

Many thanks,

1 Like


Sorry. Currently this is not available from the inspector. I have it on my todo list, but I haven’t gotten to it yet.

If you are using a grid graph you can set it afterwards relatively easily though. You can subclass the GraphUpdateObject like this:

public class MyGUO : GraphUpdateObject {
	public override void Apply (GraphNode node) {
		RaycastHit hit;
		if (Physics.Raycast((Vector3)node.position + Vector3.up, Vector3.down, out hit, 2)) {
			var layer = hit.transform.gameObject.layer;
			if (layer == 0) {
				node.Tag = 0;
			} else if (layer == 3) {
				node.Tag = 5;
			// ...

Then you can use it like

var guo = new MyGUO();
// Make sure the bounding box is really large
guo.bounds = new Bounds(,*1000);
guo.updatePhysics = false;;

This will fire a single raycast for each node and change the node’s tag according to whatever object that was hit.