This topic contains 7 replies, has 2 voices, and was last updated by  Sigil 2 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #39171

    Stream
    Participant

    Do you have to create a class file for every custom action? And in the custom action class, since it’s overriding, you can skip the Start and the end part, even when using the ai argument right?

    Also why doesn’t rain set memory variable from behavior tree ? why do I need custom action for that too?
    Thanks

    • This topic was modified 2 months, 1 week ago by  Stream.
    #39173

    Sigil
    Keymaster

    Every CustomAction needs to be a separate class, although they can inherit and build on each other. If you define public variables of the type Expression it will include those in the editor for you. Look around the forums a bit for examples of that (you can use google to do a quick search of the forums).

    As for them being separate files, that is a Unity thing, I don’t think RAIN will care, not sure if that is what you were asking though.

    You can delete Start and Stop if you don’t need them, although Start is good for setting everything up so that your Execute is fresh.

    You can use an Expression node to set any variable in memory, like (myNewVariable = “Blah”).

    #39178

    Stream
    Participant

    Bug in the asset? put a constraint, and evaluate expression as the last child element (mine was bool type if that matters), it does NOT set the memory variable, but it works if the evaluate expression is the first

    • This reply was modified 2 months, 1 week ago by  Stream.
    #39187

    Sigil
    Keymaster

    You’d have to show me the tree, maybe a screenshot. Or you can write it out in pseudocode (using the pre/code tags) like this:

    root
        sequencer
            expression (expression: myTarget = navigationtarget("Navigation Target"), return: success)
            move (move target: myTarget)

    The expression will only work if it gets reached, you mention that it at the end of something, if any of the previous children failed it wouldn’t get executed as well.

    #39191

    Stream
    Participant

    I understand what you mean, but that’s not the case.

    Behavior Tree Code

    root
        parallel<-- putting sequencer also doesn't matter, tried both
            detect (visual sensor - eyesight) [form Variable = formVar]
            constraint (formVar != null)
                     Move (mountVariable)
                     expression (PlayerInSight = true) Here, it doesn't set it to true, if but does set it if it's put before move


    But
    DOES set when positioned Before Move

    • This reply was modified 2 months, 1 week ago by  Stream.
    • This reply was modified 2 months, 1 week ago by  Stream.
    #39197

    Sigil
    Keymaster

    OK, well very likely what is happening is that your AI is working on moving towards the player. The move node will hold on to execution until it gets within close enough distance of its target.

    Try it out in the behavior tree debugger and you should see what is happening. Select your AI and change the drop down in the behavior tree to the Current AI (top option I think). When you press play it should light up with colors representing what is going on. What you will probably see in the first image is that the move node is yellow, and the expression isn’t lit yet.

    A few notes on your tree:

    When you have multiple items in a constraint it behaves like a sequencer. So it will wait until the first item returns success before moving on to the next. In your case it is waiting for the move node to finish before evaluating the expression.

    Your expression node is currently set to return the evaluated result, and since it is an assignment (PlayerInSight = true) it is returning whatever PlayerInSight equals when you’re done (obviously true in this case). While it works this time, it may not be what you intended, for instance if you were to do PlayerSpeed = 0 instead, it would have returned 0, which ends up being treated as a failure. Generally when you are doing an assignment you probably want to set it to return success or failure explicitly.

    Let me know if my first observation is off, otherwise come back if you have more questions.

    #39212

    Stream
    Participant

    Could you please answer these questions about sensors

    1. The Visual Sensor, it looks like it’s doing distance or range check + Vector angle calculation, and not a raycast? because it also detects the Target even when it’s behind a wall. Normally, how do you make it a realistic visual Line of Sight in that case? (The outdated? doc mentions it, but I couldn’t find it among Visual Sensor setting)

    2. The Audio Sensor, does it get triggered if the Aspect comes within the Range and plays any sound, or is it just like a Visual Sensor that it detects Aspect regardless of whether the Aspect is playing any sound or not?

    Now let’s say the Aspect is within the Audio Sensor range, but the Audio clip’s range is NOT actually reaching the AI for eg:

    I mean, the Audio sensor range say is set to 30, the Aspect is just in that range (eg. 25 units away), but the Audio Clip is supposed to be heard say at the distance of 5 only.
    Will the AI still detect it? (I have no actually worked with sound so I am not sure and asking you)

    Thanks

    • This reply was modified 2 months ago by  Stream.
    #39223

    Sigil
    Keymaster

    1) Select “Show Advanced Settings” from the component menu (gear icon, upper right of AI Rig component). Line of sight should show up after that.

    2) The audio sensor will only check audio aspects that fall within its range. For any audio aspect within the range it will check if the audio clip is playing, if the sensor is within the max distance of the audio clip, and if the volume of the audio clip is over the volume threshold (given the range and falloff of the audio clip).

    So using your example: If the audio clip can only be heard 5 meters away, the audio sensor will only detect it when it is 5 meters or closer, even if the range is set to 30. The range on the audio sensor is just to keep us from having to flip through all the audio aspects in the scene… in a future version we may remove it and rely solely on the audio aspects and the associated audio clips volume range.

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

You must be logged in to reply to this topic.