Behaviour Tree on Instantiated Object

Badamb

New member
Hi,

In the project I'm working on I'm playing around with AI breeding. They agents lay eggs that hatch and instantiate more AI agents after a timer gets to zero. When this happens I noticed the behavior tree on the newly spawned clones seems to just hang and the clones just stand there.

Would pooling external behavior trees be the way to solve this? If so I'm a little confused with how to assign the tree to the newly instantiated clone.


If not pooling then is there another way to get the tree on the clones to start?

Apologies if this is blatantly obvious! So far I've been able to find the answer whenever I've gotten stuck but can't seem to figure this one out.

Really loving the Behavior Designer asset and packs, it's one of the best things I've purchased on the store.

Cheers.
 
Happy to hear that you're enjoying Behavior Designer!

External trees won't help in this situation as if the agent isn't moving it doesn't sound like the tree is active. What does your tree look like?
 
Is that screenshot when the game is running? It doesn't look like it is active yet. Do any of the tasks turn green when you respawn? Are you able to reproduce it within a fresh project with a minimal behavior tree?
 
Sorry Justin this is how it looks when it's running. Sometimes it'll turn green down to the Swarm task but the clone never moves or changes task. The tree works fine on the animals that are pre loaded if that makes sense?

Just tested it on a fresh project with a tree consisting of just the Wander task and the AI works fine.

Thanks!


BehaviorScreenshot.png
 
Are you getting any errors? Generally when that happens it is because an exception is thrown and the tree can't continue.
 
Actually yes I hadn't noticed! Whenever I try spawning a new character I get the following:

"Resume" can only be called on an active agent that has been placed on a NavMesh.

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
 
That does look like the cause. Here's a thread that has some potential solutions:


My guess is that either the agent isn't near the navmesh or the NavMeshAgent isn't enabled.
 
Yeah that was the problem! When I disable and reenable the NavMeshAgent it all works.

Thanks for your help and patience!
 
Top