Using existing scripts for Behaviours trees / designer

Silver100

Member
I'm new to behaviour trees was thinking of getting the behaviour designer movement pack (I'm only concerned with movements' for now). At the moment I have created an enemy AI system with scripted movements animations triggers using range & attack handling scripts. One of the problems I encountered is resetting nav agents path, when it comes to switching characters in run time. At the moment I use 2 types of AI to overcome this hurdle; a 'nav agent follow script' which I find works best for scene with one player, then the other 'none nav agent follow script' (works but not as good at keeping stable) Switching to none nav type scripts when it comes to character swapping, as a resolution for now. Basically one of my scenes has a character runtime switch method using 2 camera x 2 characters works but not able to use my preferred nav agent method due to limitation of my methods used & understanding of AI pathfinding and resetting.
I'm just wondering if Behaviours trees/ designer would help my issues with resetting nav agent path and which version would be best & can I use with my scripts?
 
Last edited:
Can you explain your "none nave agent based follow" solution? So you're switching between moving the character with the navmesh versus nothing at all? Why do you need to do this?
 
Swapping out a script I meant to put, rather than my usual nav path finding method, to just a simple follow player script for scenes with character & camera switching. The basic custom follow script I'm using has a quaternion look rotation to follow the player.
If I use a custom path finding follow script in a scene where there is character swapping and camera swapping, the enemy agent proceeds to follows the previous character, or even dead character. The nav script is using nav.destination method where I was unable to set a new destination. The quaternion look direction method just follows player directly with no path calculated, however has an issue of tilting upwards if the player jumps or height changes.
 
Last edited:
Behavior Designer itself is a behavior tree framework meaning it sets up the flow for your AI. There is integration with the NavMeshAgent component with the Movement Pack. You are also able to create custom tasks, as described on this page:


For your situation you would be able to setup a behavior tree that switches between the navmesh and following the player. In the Movement Pack there is actually a follow script that you would be able to use. You will not need to directly set the destination position as the Movement Pack tasks will take care of that for you.

Does that answer your question?
 
Thanks so can I also literally drop in all my current AI scripts I have already or would I need to follow the opsive frame work ?
 
Last edited:
It really depends on your setup but since you are controlling the NavMeshAgent with your scripts you would switch to the Movement Pack tasks instead. For anything extra you can create a new task that then calls your existing scripts, or just pull everything into the task. I do think that Behavior Designer would make the structure more organized.
 
Thanks for the info. Sounds like it could add more flexibilty to what I am doing and eventually make it much easier to manage, but would initially require some learning and restructure. I managed to fix the tilting of quaternion look direction by clamping rotation on the X, & Z axis. A grounded enemy character only needs to follow rotation on a Y axis.
 
Last edited:
Top