News Forums RAIN General Discussion and Troubleshooting Audio Sensor issue

Tagged: ,

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

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #40057

    kilfeather94
    Participant

    I’m just having a little trouble with Audio detection. I have an Audio Sensor set up in my enemy rig and whenever it hears a sound from my player entity, it will move towards that sound. The problem is, the enemy will only move towards the sound when it’s continuously playing. As soon as the sound stops playing, the enemy resumes to it’s patrolling state. Is there any way I can get the enemy to move towards the sound even after it’s finished playing?

    #40078

    Sigil
    Keymaster

    So you probably have the behavior tree setup in such a way that the detect node is in a parallel towards the top and setting some variable that you are heading towards. Given most of the examples out there there is probably a constraint guarding your movement in the event that the detection fails as well. Assuming that is the case, the detect node will assign the target when it detects it, but will assign null when it doesn’t. The constraints head to the target when it isn’t null, but patrol otherwise.

    So lets just change it around a bit, you can do something like this for instance (instead of the other setup):

    sequencer
       parallel (succeed: any, fail: any, tie breaker, fail)
          detect (repeat: until success, sensor: "Audio Sensor", aspect: "Audio Aspect", form variable: audioTarget)
          waypoint patrol (waypoint route: "Waypoint Route", move target variable: waypointTarget)
             move (move target: waypointTarget)
       move (move target: audioTarget)

    You’ll probably need to change some of the values to match your scene.

    So that will run the patrol while trying to detect the audio aspect. The second it detects, it will return success and move on to the move node below.

    • This reply was modified 5 months, 2 weeks ago by  Sigil. Reason: added repeat to detect node
    #40091

    kilfeather94
    Participant

    Just tried that out there. The Audio detection works now, but I just have one other problem after trying this.

    Here’s a screenshot of my Behaviour Tree: http://imgur.com/55EqDpj

    The patrol state is timed so the ‘Patrol Time Sequence’ node waits for 10 seconds, then the ‘Pause Expression’ sets a boolean called ‘isPaused’ to true. Then in the ‘Pause’ constraint node, it has a timer which runs for a couple of seconds and then sets the ‘isPaused’ boolean to false and the enemy resumes patrolling. Problem is, after I added the ‘Audio Detection’ sensor and ‘Move to Sound’ action, the enemy keeps patrolling but won’t pause anymore.

    • This reply was modified 5 months, 3 weeks ago by  kilfeather94.
    • This reply was modified 5 months, 3 weeks ago by  kilfeather94.
    #40114

    Sigil
    Keymaster

    Sorry for the late reply:

    Looks like I missed something in my behavior tree, it needs a “repeat: until success” on the audio detect node. But aside from that it also needs some reworking given that you need a timer as well.

    So in addition to adding the “repeat: until success” on the audio detect, I’d move the move node (Move to Sound) outside of your parallel and right after the parallel, but still in the constraint. We need the move to only run in the event that the detect node successfully detects something. A constraint acts like a sequencer when it has multiple children (if you want to be more explicit you could put them in a sequencer as well). You should also explicitly tell your expression (Pause Expression) to return failure.

    #40130

    kilfeather94
    Participant

    No problem.

    That did the trick. Works fine now. Thanks very much for the help

    #40180

    kilfeather94
    Participant

    Hey, sorry to bother again with this, but just having an issue with Audio Detection when the enemy AI is in a searching state. The example you gave previously works fine when the enemy is in the patrol state, but I can’t seem to get it to work when the enemy is searching for the player. here’s an image of the search state in the behaviour tree: http://imgur.com/7wwYpFE I can get the audio detection to work, when ‘Succeed’ in the parallel node is set to ‘Any’. But the problem is, when Parallel is set to ‘Any’, as soon as the enemy enters the ‘Search’ state, it’ll immediately jump back to the ‘Patrol’ state. If I leave the Succeed set to ‘All’ in Parallel, the enemy will stay in the Search state, but won’t move to the sound when it detects it.

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

You must be logged in to reply to this topic.