Dynamic Character Radius

Hi,

I have a question about the Characters Radius and the Pathfinding, I have different “creeps” and some of them have a bigger character Radius that others, so my question is How can I handle that?

Can I have different RecastGraphs with different Character Radius configurations and force a Seeker to use a custom recast graph to calculate his Path?
Can I have different RecastGraphs over the same Terrain without conflicts?

Thanks in Advance.

Ruben.

I saw that the seeker has the option to SearchPath with a custom graph mask to indicate in which graphs search for a Path,

StartPath (Path p,OnPathDelegate,callback = null,int graphMask = -1),

Now my question is about to have 2 or more recast graphs with the same Bounds.

In case there is no posibility, I was thinking about a dirtyhack, I dont know if this will work:

Imagine, World size 400,100,400
First positioning my map On Position x=0,y=0,z=0, and Bounds Center x=200,y=50,z=200, and scan my first recast graph with the first character radius.

Second , move the terrain with an Y offset, for example to Position x=0,y=105, z=0, and scan with Bounds x=0, y=155, z=0 and the second character Radius.

Third, in the Game use the seekers with the first characters radius as normal and the graphmask of 0, and the seekers with the second character radius use an offset of Y = 105 in all Vector3 operations, and use the graphmask of 1, Will this work?

Thanks in Advance.

Ruben.

Hi

Using two recast graphs with the same bounds will work just fine.
The only thing you need to change in your approach is that the graphMask is a bitmask, not the index of the graph to search. See https://en.wikipedia.org/wiki/Mask_(computing)

So if you want to search only the first graph, set it to “1 << 0”, if you want to search only the second graph, set it to “1 << 1”, etc.

If you are very constrained on memory, you can try to use the Radius modifier script instead. It will not be able to do as good a job as different graphs, but it can work well in some cases (this is assuming you do not use the RichAI movement script which does not use modifiers).

Hi,
Thanks for your reply,
If there is 2 different graphs with the same bounds, will the UpdateGraphs(Bounds bounds) update both of them?
In case no graphMask is indicated and 2 graphs have the same bounds wich graph will be used in the path search?
If I Save both graphs with SerializeGraphs (), and load again later with DeserializeGraphs() the graph order will remain? (to use it with the graphMask).

Thanks for your time.

Ruben.

Hi

Yes, it will update both. If you create a GraphUpdateObject and pass that to the UpdateGraphs method, you can specify which graphs to update using the GraphUpdateObject.nnConstraint.graphMask field.

It will use the closest graph in the path search. However if they occupy the same bounds, that can lead to problems since it will pick different graphs at different times. Therefore a graph mask is nice to set.

Yes, the graph order will remain the same.