GraphNode.Flags

I was just fooling around with flags of a node. I looked for some information and couldn’t find anything other than “Holds various bitpacked variables.” With some testing I found that the flags return the following values. I am curious if they would remain consistant?
0 = collider placed on top, walkable = false.
3 = reachable, walkable = true.
5 = unreachable, walkable = true

That’s a lot of valuable information from a single node lookup. those readings are from

GraphNode n1 = AstarPath.active.GetNearest(new Vector3(-8.5f, 0, 8.5f)).node;
Debug.Log(n1.Flags + " walkable " + n1.Walkable);

Hi

Yes, the flags field is used to store a lot of information.

You can actually find a lot more information by looking at the patterns in the code, right now it is:

Bit
0: Walkable
1-10: Area
11-16: Graph Index
19-24: Tag

Accessing the named properties on the node does the necessary bitwise operations needed to extract the values from that single field.

Previous versions had a whole table in the documentation specifying what every bit was. But I removed it… I am not sure why now, it was a long time ago. I think a partial reason was that some of the fields use more or less of the flags field depending on special compilation directives ( like ASTAR_MORE_AREAS ).

See also: https://en.wikipedia.org/wiki/Mask_(computing)

As a side note, GridNode.gridFlags uses bits 0-7 to specify in which directions it has a valid connection to. Some other bits are used for the walkability before erosion is applied, and then some temporary variables.

https://en.wikipedia.org/wiki/Mask_(computers)
That is an interesting read. I re-linked it since it has an _( it breaks the link and redirects you to a normal mask lol.

Good to know about the grid flags, that will come in use.

On a side note of my own, has adding and removing individual connections been implemented in any of your versions? They are not yet implemented on mine. Or are you still working on those?

That would be handled by the AddConnection and RemoveConnection methods.
They should be working in 3.4.x at least.

Ah, I’m going to have to look into that. The ones I have just throw a not implemented error. When I check, that throw is the only line of code.

Make sure you are using the latest version. I might have fixed the GridGraph implementation for them in the latest update.

I doubled checked. I have 3.4.0.4 from http://arongranberg.com/astar/download.
This version has the same issue for adding and removing single connections
GraphNode.cs public override void RemoveConnection (GraphNode node) { throw new System.NotImplementedException("GridNodes do not have support for adding manual connections"); }
this versions remove connection also needs the clear connections fix (I’m sure you are already aware of that though)

Also Happy New Year! lol I don’t expect an answer from you for a few days, so you better be having a good time! :stuck_out_tongue: