- A* version: 4.2.17
- Unity version: 6000.0.38f1
Sorry for bothering you, I’m doing 2D game and I need to implement AI Pathfinding, I found your package and it’s pretty good for me, my obstacle is spawned during playing mode and I updated the graph for its position
However, problem here that my seeker keep moving forward although there is a obstacle in front of him instead of dodge/move around the obstacle, he should know how to dodge the obstacle and find other way
Tried many ways with Seeker.StartPath, AIPath.SearchPath, but the result still the same.
Here is my NPCController.cs
if (_aiDestinationSetter.target != null)
{
_aiPath.destination = _aiDestinationSetter.target.transform.position;
return _aiPath.desiredVelocity;
}
return Vector2.zero;
Spawner.cs
private void UpdatePathfindingGraph(GameObject go)
{
if (Pathfinder == null) return;
// skip only the types you really want to skip
if (_type == SpawnerType.BUSH || _type == SpawnerType.CROP) return;
Vector3 newPosition = go.transform.position;
if (go.TryGetComponent(out TreeObject treeObject))
{
float offsetY = 0;
// Down the position for bottom tree
if(treeObject.type == TreeObject.Type.THIN)
offsetY = 0.5f;
else if (treeObject.type == TreeObject.Type.NORMAL)
offsetY = 1f;
newPosition.y -= offsetY;
}
Bounds b = new Bounds(newPosition, Vector3.one);
// do a proper GraphUpdateObject with physics
var guo = new GraphUpdateObject(b)
{
updatePhysics = true,
modifyWalkability = true,
setWalkability = false,
};
AstarPath.active.UpdateGraphs(guo);
}