I have an NPC moving between several waypoints using NavMeshAgent. When the NPC arrives to waypoint N, it gets a reference to the next point N+1 (by querying the Nth waypoint) and stores it in the Blackboard variable that is used as the next NavMeshAgent target.
The NPC has a BT and the waypoints have FSMs. My question is how would the waypoint FSM pass a reference to the next waypoint to the NPC. What part (or all) of that could be implemented purely with NodeCanvas?
Can you please provide a bit more information as of why the waypoints have an FSM and what is the functionality of that waypoints FSMs?
Generaly speaking, it is possible to get or set variables on blackboards other than the one the graph is using by default. This can be done with the “Get Other Blackboard Variable” or “Set Other Blackboard Variable” actions respectively.
Here is a usage example for your convenience:
– Notice that here, the “Target (Self)” has been overridden to point to the target Blackboard gameobject (in this case “NPC BT”) in which we want to set one of it’s variables.
– Next we need to select the variable type we want to set by pressing the “Select Target Variable Type”. In this case I selected the “Transform” type.
– Finally we set the “Target Variable Name” which we want to set and the “New Value” we want to set it to.
Please let me know if this works for you, or if you need any further clarification.
Thanks!
>> Can you please provide a bit more information as of why the waypoints have an FSM and what is the functionality of that waypoints FSMs?
In my game the waypoints are not simply Vector3 coordinates. They are sort of “intelligent”. For example, they change textures depending on whether the NPC is nearby. They will give the next waypoint only after the NPC provides a “password”, etc. It seems that FSM is the most logical way to go, but I’m open to suggestions 🙂
Thank you for explaining “Get Other Blackboard Variable” and “Set Other Blackboard Variable” actions. I think this should work in my situation. But I was also thinking about building a custom action that would encapsulate a function call to the waypoint that would return the next waypoint. This seems to be more straight-forward. Do you think there are any disadvantages in doing that vs. what you described? Thanks again!
Thanks for the follow up.
Creating custom action/condition tasks, is certainly a better way to go about implementing functionality and make the graphs do what you want them to do. There is certainly no disadvantage in creating custom tasks! 🙂
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.