Seek Task Status Stasy in Running State After BehaviorTree Gets Restarted

pako

New member
Hi,

I have a very simple Behavior Tree with just the Seek Task from the Movement Package.

BT-Seek.JPG

What I wanted to accomplish is this:

1. When first started, I set the Seek Target to the Player GameObject through code.
2. If/when the Enemy with the BT arrives at the player I need to reset the Enemy back to its spawn point (level restart). This was impossible to do with just a simple [enemyTransform.position = spawnPointPosition], because apparently, the NavMeshagent, probably coupled with the BT wouldn't let it happen. I tried many hours trying to accomplish this simple task but it proved impossible. So, I decided to tell the Enemy to go back to its spawn point using the same BT (as above), but in this case, I set the Target to the SpawnPoint GameObject through code. This works fine with one exception (below).
3. As I need to stop the Enemy running animation through code (set the Running anim bool parameter to false), I added the Send Event task, as above. This works fine when the Enemy arrives at the player, but when going back to the Spawn Point It doesn't get triggered. I noticed that both the Seek and Send Event tasks have the Green success tick (from the first time going towards the player). Although the Seek task turns Green (running state) the second time (going towards the spawn point), it never changes its status to success, even though I can see visually that the enemy has arrived at its spawn point. So visually, the enemy stops moving when it arrives at its spawn point, but the running animation continues to play.

Any help would be appreciated.

Thank you
 

pako

New member
I finally figured it out. I had set the NavMeshAgent arrive distance to 1, but the Seek arrive distance to 0.5. When I set them both to either 1 or 0.5 it worked.

Nevertheless, I don't understand why seek succeeded when going towards the player, even though the arrive distance were different.
 
Top