NodeCanvas Forums › Support › Setting up AI with FSM top-level and BT's sub level + related questions › Reply To: Setting up AI with FSM top-level and BT's sub level + related questions
Hello!
I saw your other post 🙂 Indeed FSM top level and SubBTs is what I think is best combination of FSMs and BTs.
Thanks a lot for your thorough explanation and details. To answer your questions:
1. NC can work with custom types and interfaces prety well. The first thing you would like to do, is open up the Preferred Types editor (Window/NodeCanvas/Preferred Types) and add your interface or any other type in the list. From there on, you will be able to create blackboard variables of IDamagable type for example.
Also, you are able to create BBParameters of any type including interfaces. So you are free to do something like this for example within a custom Task:
1 2 3 4 5 6 7 8 9 10 11 |
public class Example : ActionTask{ public BBParameter<IDamagable> target; protected override void OnExecute(){ Debug.Log(target.value.isDead()); EndAction(true); } } |
And of course you are able to link the above parameter to any blackboard variable of the same or assignable type as well! 🙂
So for example this BBParameter
Furthermore, you are also able to create Tasks with a specific ‘Agent Type’ by using the generic version of tasks like for example:
1 2 3 4 5 6 7 8 |
public class Example : ActionTask<Damagable>{ protected override void OnExecute(){ EndAction( agent.isDead() ); } } |
Doing the above, is relevant to THIS link in the documentation by the way.
2. To make the transition happen from Wander to Attack state, there are a lot of ways. What I would do, would be to have a variable “Target” on the blackboard. Within the Wander BT state, when a target has been found, set that variable and have a transition condition from one state to the other checking whether or not the “Target” variable is null. If it’s not null, thus we have a target found, the transition from Wander to Attach would take place.
Let me know if you have any more questions or need any clarifications at all 🙂
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh