Please, check the two screenshots in the attachment to this post to get a better sense of the issue I describe below. Thank you.
The first screenshot shows the tree and the inspector of the Seek block, plus the window of the Global variables, while the second screenshot shows the game running with the zombie basically kissing the avatar while the tree insists that the Seek block is still running.
A long ago I put together the visual script in the picture using Behavior Designer and so far it has worked well: the Find block fills up Global/Avatar with a reference to the Avatar GameObject during bootstrap, then CanSeeObject looks for him, Seeks chases him, and finally Damage hurts him, then after a small delay, it all repeats itself. Currently, I have this visual script on a zombie NPC that tries to damage the avatar.
Today I decided that I needed to use NavMesh Cuts for the car, so I "ported" the navigation system from the builtin NavMesh in Unity to the A* Pathfinding Pro plugin, and I did all the necessary changes, including swapping the Seek block I have been using so far with the one from the A* Pathfinding Pro integration, and I noticed how the zombie keeps moving towards the avatar even after it has reached him and never reaches the Damage block. To be clear, the only block that has changed is the Seek one, while all the others are the same as before the "port".
After some debugging, I figured that OnUpdate of the Seek block never returns TaskStatus.Success:
public override TaskStatus OnUpdate()
{
if (HasArrived()) {
return TaskStatus.Success;
}
SetDestination(Target());
return TaskStatus.Running;
}
The reason is that HasArrived() never returns true:
protected override bool HasArrived()
{
return !agent.pathPending && (agent.reachedEndOfPath || !agent.hasPa th);
//return !agent.pathPending && (agent.reachedDestination || !agent.hasPath);
//return !agent.pathPending && (agent.remainingDistance < 0.85f || !agent.hasPath);
}
As you can see I tried a couple of workarounds, and the bottom one works for me (after establishing that the zombie always gets up to about 0.8f from the avatar) while the first workaround doesn't work, i.e. checking for reachedDestination produces the same result as checking for reachedEndOfPath.
Notice that even when the zombie is face to face with the avatar, the code keeps producing these logs:
Path Completed : Computation Time 0.00 ms Searched Nodes 2 Path Length 2
again and again, because clearly the Seek block doesn't think it has reached the avatar yet.
It seems to me that the current code in the Seek block for the A* Pathfinding integration currently only returns TaskStatus.Success if the position of the zombie is more or less identical to the one of the avatar, but as it is currently, this code will never work because both the zombie and the avatar have a capsule collider added by the Ultimate Character Controller wizard that prevents them from ever overlapping (that is a good thing, but still it seems to prevent TaskStatus.Success from being returned.)
What am I missing?
Any help is welcome.
Thank you, Chris
The first screenshot shows the tree and the inspector of the Seek block, plus the window of the Global variables, while the second screenshot shows the game running with the zombie basically kissing the avatar while the tree insists that the Seek block is still running.
A long ago I put together the visual script in the picture using Behavior Designer and so far it has worked well: the Find block fills up Global/Avatar with a reference to the Avatar GameObject during bootstrap, then CanSeeObject looks for him, Seeks chases him, and finally Damage hurts him, then after a small delay, it all repeats itself. Currently, I have this visual script on a zombie NPC that tries to damage the avatar.
Today I decided that I needed to use NavMesh Cuts for the car, so I "ported" the navigation system from the builtin NavMesh in Unity to the A* Pathfinding Pro plugin, and I did all the necessary changes, including swapping the Seek block I have been using so far with the one from the A* Pathfinding Pro integration, and I noticed how the zombie keeps moving towards the avatar even after it has reached him and never reaches the Damage block. To be clear, the only block that has changed is the Seek one, while all the others are the same as before the "port".
After some debugging, I figured that OnUpdate of the Seek block never returns TaskStatus.Success:
public override TaskStatus OnUpdate()
{
if (HasArrived()) {
return TaskStatus.Success;
}
SetDestination(Target());
return TaskStatus.Running;
}
The reason is that HasArrived() never returns true:
protected override bool HasArrived()
{
return !agent.pathPending && (agent.reachedEndOfPath || !agent.hasPa th);
//return !agent.pathPending && (agent.reachedDestination || !agent.hasPath);
//return !agent.pathPending && (agent.remainingDistance < 0.85f || !agent.hasPath);
}
As you can see I tried a couple of workarounds, and the bottom one works for me (after establishing that the zombie always gets up to about 0.8f from the avatar) while the first workaround doesn't work, i.e. checking for reachedDestination produces the same result as checking for reachedEndOfPath.
Notice that even when the zombie is face to face with the avatar, the code keeps producing these logs:
Path Completed : Computation Time 0.00 ms Searched Nodes 2 Path Length 2
again and again, because clearly the Seek block doesn't think it has reached the avatar yet.
It seems to me that the current code in the Seek block for the A* Pathfinding integration currently only returns TaskStatus.Success if the position of the zombie is more or less identical to the one of the avatar, but as it is currently, this code will never work because both the zombie and the avatar have a capsule collider added by the Ultimate Character Controller wizard that prevents them from ever overlapping (that is a good thing, but still it seems to prevent TaskStatus.Success from being returned.)
What am I missing?
Any help is welcome.
Thank you, Chris
Attachments
Last edited: