Hi I’m looking for some advice on the proper way to use your node canvas tool.
So I want to use node canvas to find targets (runtime instantiated), navigate to targets (navmesh agents) or even keep distance. Then I want to track cooldowns for basic attacks, skills, etc. Also, I use a prefab (runtime instantiated) for both the enemy and player, and give them a unique behavior tree based on unit type. Think marine, tank, helicopter, what have you. So the behavior tree is not on an object until runtime.
I also want the list of targets to be added to a list as they get in range of the unit in question.
The ways I’ve found that seem to help me do what I want would be calling functions, but again I can’t use self binding variables to get my script/function because I instantiate the units at runtime, and all units have the same prefab and I swap in the behaviour tree then. There must be a way that I’m not finding.
Regarding targets I felt like the only way is to get a list of targets from a script, but I’m struggling to access variables and functions in scripts from within node canvas.
Any advice is welcome. I read through the docs regarding custom scripts and while I feel like I’m fudging my way through, I thought maybe you’d have advice on the right way to do things rather than a Hacky way.
You can call functions with Execute Function action task on a gameobject monobehaviour even if you creating asset-based behaviour trees and are dynamically adding the behaviour tree in runtime, as long as the gameobject does have the monobehaviour that the Execute Function targets when it executes of course.
The same is true for all reflected tasks. You can just select the target function/field/property of a monobehaviour, even when you are designing asset-based graphs. In runtime the task will work if the monobehaviour and target member (function/field/property) can be found on the target gameobject.
Please let me know if that helps or if you need further clarification.