News › Forums › RAIN › General Discussion and Troubleshooting › Property Editing in Runtime?
Tagged: Behavior Tree, properties, property, runtime, waypoint
This topic contains 3 replies, has 2 voices, and was last updated by skylem 1 month, 1 week ago.
-
AuthorPosts
-
May 28, 2022 at 2:09 am #38141
Hi so i’ve been using rain the past few days to design a new AI that im working on for a friends game, i have tried to find an answer to my question through searching and even tried some experimentation with no luck, All i want to know is how to change the fields within a behavior tree to be more specific, i want to know how i to change the string field Waypoint Route of my Patrol Route Node in my new Behavior tree, through code at runtime.
Reason. All of these creatures will be spawned into the game at runtime, each creature is spawned with its own unique patrol route the player is able to assign waypoints to, commanding the creature to patrol an area set by the player, however currently since the patrol routes all have shared names creatures with intersecting patrols get confused and begin following routes that are not their own, my solution to this is to simply to use the UniqueID/Name of the creature to name its corresponding patrol route(i have gotten this far), then Rename the Waypoint Route in the behavior tree that my creature is trying to follow (this is what im unable to work out). Hoping someone here is able to help me out i am not new to RAIN but this is the first time i’ve ever had a need to change a Behavior tree’s Node property at runtime.
Regards and thanks Steven.May 28, 2022 at 8:06 am #38144The waypoint route field is an expression field (not a string field) - you can tell by the bold “e” next to the field. Expression fields can contain variables. So instead of setting the Waypoint Route to “Route 1″ or something like that, you could set it to varCurrentRoute.
Then in code, or even directly from the behavior tree, you can just change the value of the variable. To do it from within the tree, just use an expression node. The expression would be varCurrentRoute = “Route 1″ or similar. Then set the return value on the expression to succeed (not evaluate).
From code, you just need to set the variable value in AI memory:
ai.WorkingMemory,SetItem<string>("varCurrentRoute", "Route 1"); //or ai.WorkingMemory.SetItem<WaypointSet>("varCurrentRoute", tWaypointSet); //if you have direct access to the waypoint set.
May 28, 2022 at 5:01 pm #38153oh wow so simple, thanks heaps for the help prime, this will go a very long way towards my rain development.
May 28, 2022 at 6:23 pm #38154Ok so just incase anyone happens across this looking for info this is what i ended up with in the end.
aiRig.AI.WorkingMemory.SetItem<string>(“varCurrentRoute”, transform.name + “Patrol”); to change a string expression in my behavior tree, then using that variable to fill the Waypoint Route.
gives the creatures unique ID name to the patrol route.
-
AuthorPosts
You must be logged in to reply to this topic.