News › Forums › RAIN › General Discussion and Troubleshooting › Constraints
This topic contains 3 replies, has 2 voices, and was last updated by prime 2 months, 3 weeks ago.
-
AuthorPosts
-
December 11, 2022 at 6:01 pm #34727
How would I set a constraint on a sequencer saying that it cannot go through if the player is a certain distance away
i have
sequencer
-detector
-mecaparam
-custom action
-parallel(succeed any)
—move (to close enough distance 3) —- he gets here and i dont want the sequencer to reloop through and consistently change that parameter with mecaparam, because its immediately jumping out of the parallel every time because its already close enough.
—timer(5 seconds)December 12, 2022 at 6:06 am #34736There currently isn’t a distance function in RAIN expressions. That means you will have to rely on code to calculate the distance between 2 objects, or between the AI and some other object. Just use a custom action to set a memory variable.
To force the sequencer to FAIL whenever the AI is already close enough, add an “Evaluate Expression” node as the first node under the sequencer. Do the distance check in that, so:
SEQUENCER
— EVALUATE (distance > 3)
— ALL YOUR OTHER NODESIf you don’t want a FAIL case, then use a selector instead
SELECTOR
— EVALUATE (distance > 3)
— SEQUENCER
— — ALL YOUR OTHER NODESDecember 12, 2022 at 8:52 am #34752Im also having trouble setting my timer to a public instance variable in my custom action
i said public double timer = 0.0;, set it to 80.0 in the execute function in the custom action, then tried to use a timer action, setting the time to “timer” ( i tried timer without quotes as well), and it doesnt work. Any suggestions? Im actually trying to utilize the ai mind. Is there a way I could set a mind variable to my timer data member? I tried ai.Body.Mind.time = timer; ai.Mind.time = timer; and ai.time = timer;
- This reply was modified 2 months, 3 weeks ago by rbranch1.
December 12, 2022 at 9:11 am #34754First, you should probably use float instead of double. Especially for time.
If you are trying to make the value of the timer variable available in AI Memory and accessible by the Behavior Tree Expressions, then you will need to do this in your custom action:
ai.WorkingMemory.SetItem<float>("timer", timer);
The AI mind doesn’t have a time variable. The right approach is to use WorkingMemory to store information.
-
AuthorPosts
You must be logged in to reply to this topic.