Currently, there are two actions that all agents in my game share. I was wondering what the best practice would be for initializing a graph that is unique to that agent but contains the default actions required by all agents. I have considered the following implementations:
Have my agent (which extends BehaviourTreeOwner) create a default graph that has the required actions for my agent when the script is attached to an object by overriding the Monobehaviour Reset() function. If I go this route, how would I go about serializing the graph object to an unbound graph asset that can potentially be reused. Additionally, going down this route, is there a function to reset the graph UI to look more organized? I tested this implementation and all of the states were kind of stacked on top of each other which I could see being mildly annoying as I create more agents.
Create a sub tree with the required actions and have our designers remember to attach it to the agent every time./li>
Have our designers not forget to attach the actions.
Of all of these, the first seems the least error prone from the designer usability perspective, but I am not sure if this would be considered best practice.
Hmm. Considering that I’ve understood correctly, I think that a combination of #1 and #2 can probably be the best approach for this.
What I mean by that is something like this:
1) Pre-create a BehaviourTree Asset with required actions/nodes/setup and store it in your project (maybe in a Resources folder to avoid direct reference) 2) In your BehaviourTreeOwner derived agent and within the overriden Reset() method, instead of coding the graph, use the pre-created graph and assign it to the agent. This can easily be done with the GraphOwner.SetBoundGraphReference(Graph) method.
Doing it this way, avoids the need to manually handling serialization as well as coding the graph’s layout since the graph is already pre-made.
Let me know what you think and if this works for your use case.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.