Can you have multiple tags on a node?

Hello,

So, I’d like to have multiple tags on a node. Do tags work with bitshifting? For example if an entity was to fly over water, I’d want that nodes tag to tell me that it is water (thus keeping land-walkers from walking over the node) and that an entity is over the node. That way when the entity leaves that node, i don’t have to store a variable of what the old tag was and replace it.

There is no real support for it (well, there is the ConfigTagsAsMultiple compiler directive, but I am removing that because it didn’t work out well). However you can easily cheat a bit to get the desired behaviour.
Since there are 32 possible tag values on each node, we can use that as a bitmask and store 5 different tags (one for each bit, 2^5 = 32).
So you can do

node.Tag = 1 << 1 | 1 << 4; // Use tag 1 and 4

If you use tag-based penalties you will have to calculate the values slightly differently but otherwise everything should work just as usual.

the problem is the seeker would mess up or i would have to account for that better.

Is it either possible to:

  1. Add a multi-tag variable separately down the line?? Something that offers the same seeker tag mask support but with bhtshifting?
  2. Extend grid graph myself to support a bit shift tag mask? The question there is how do i pass the bit’s onto the Astar system
1 Like

Using the above “cheat”, is it possible to turn off/on only some of the bits with node.Tag and the GraphUpdateObject?

example:
Let’s say bit 0 1 and 2 store terrain type, which I don’t want to alter after initial setup.

  • initial tag could be 00000 or 10000 or 01000 or 00100.
  • enemy enters node. I want to mark the last bit (or the next to last bit) as true without disturbing other bits. That is, mark that an enemy has entered without changing the terrain type. How would/ could I do that with a GraphUpdateObject? Or directly?
  • enemy left the node. I want to mark the last bit as false without changing the other bits. Again, how would I do that?

I’d like to avoid storing the initial state in another structure as the enemy bounds may cover several terrain types. This mean a blanket “Set” without masking might override the initial terrain types.

Apologies for reviving an old thread, but this seems to be the most complete answer on this topic.

Stumbled upon the same problem.
Multiple tags on node.

I got terrain that can be ground water lava, so I use tag to restrict movement for some characters.

But I also got tags for height on some passages ex. 1 meter, 2 meters etc.
In the future I could have some more tags.

Still don’t know how to resolve this problem. I’s hard for me to accept that in the end this technology limitation might influence my design.

Just wanted to give feedback. This would be very useful feature.

@koirat

In the newer versions it is possible to override how tags and other walkability filters work. You can use the ITraversalProvider interface to create custom rules for how it should work. Maybe that would work for you. See the bottom of this page: https://arongranberg.com/astar/docs/turnbased.html#ITraversalProvider

1 Like

I have investigated it a little.
Can you tell me if I can somehow attach custom data to GraphNode (or provide my custom GraphNode) so I can later use this data in ITraversalProvider.