Open paulbreuler opened 7 years ago
I know this is quite old, but I'm going to ask anyway. 😄
Can't this be "baked" initially? As in, go through all the nodes and check for collisions with (static) objects. If they collide, they get removed from the node map. For moving objects you can do the same, while thinning out the node map in iterations. Get a path, check the nodes in the path for collisions, if any were registered (temporarily) remove collision nodes from the map and try again until a matching/non-blocking path is found.
Just wondering out loud if this is an option.
I think that would work. I don't know if I would put a hole in the map or if I would make the neighboring nodes merge into a bigger node. Thinking about things like bodies of water, assuming we can't swim in our game... I would still want info in that the object is water but is impassable so that if I jump in I can play some reaction. For a static object if it is destructible, I would still want that info as well. In both cases. I might not care about the level of detail so I would merge nodes in that area.
If we want everything to be dynamics that can be achieved as well but I don't know that I would use a well defined grid in that case.
Something like this example from on of my other projects.
/// <summary>
/// Generates a local search grid for a given start position.
/// Use this to find information about a given position such as local maxima of height,
/// cover from specific enemies, etc.
/// This can also be used recursively to find a more specific location near a position.
/// </summary>
/// <returns>The search grid.</returns>
/// <param name="startPosition">Start position.</param>
/// <param name="units">The number of units to search in any one direction. Keep this low (<8) for performance</param>
/// <param name="range">Range.</param>
protected List<Vector3> GenerateLocalSearchGrid(Vector3 startPos, int units, float unitSize)
{
List<Vector3> ret = new List<Vector3>();
for (int xUnits = -1 * units; xUnits < units; xUnits++){
for (int zUnits = -1 * units; zUnits < units; zUnits++){
Vector3 potentialPos = new Vector3(startPos.x + (float)xUnits * unitSize, startPos.y, startPos.z + (float)zUnits * unitSize);
float height = Terrain.activeTerrain.SampleHeight(potentialPos) + Terrain.activeTerrain.transform.position.y;
potentialPos.y = height + 1; //Add height of AI body
ret.Add(potentialPos);
}
}
return ret;
}
AI group up at the moment and walk in a straight line and will bump into one another until path update occurs.