This topic contains 3 replies, has 2 voices, and was last updated by  prime 2 months, 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34727

    rbranch1
    Participant

    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)

    #34736

    prime
    Keymaster

    There 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 NODES

    If you don’t want a FAIL case, then use a selector instead
    SELECTOR
    — EVALUATE (distance > 3)
    — SEQUENCER
    — — ALL YOUR OTHER NODES

    #34752

    rbranch1
    Participant

    Im 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.
    #34754

    prime
    Keymaster

    First, 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.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.