News Forums Troubleshooting Having issues with multiple detectors/sensors.

This topic contains 7 replies, has 4 voices, and was last updated by  prime 1 month, 2 weeks ago.

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

    OMGItzGnaR
    Participant

    Hey everyone! I’m going to do my best to explain the situation. My brains are fried at the moment, so I decided to turn to the community for help. :)

    So for the past couple days, I’ve been trying to create a simple Zombie AI. To wander (at the moment, follow a set path), Detect the player, and when the zombie is within a specific distance attack. All is working well, I have the zombie detect the player, and run towards him, and once he’s within a certain distance, do an attack animation. And if the player leaves the First Detector range, he returns to wandering/path. The only issue I am having, is that the Sensor for detection, (eyes) has a limited FOV. So the player can run around behind the zombie, without attracting aggro. So, naturally I thought, I’d just make another sensor with basically the same properties as the “eyes” sensor. and name it something like Sense. Here’s a screenshot of my sensors ATM.

    Sensor Setup

    The Blue sensor are the “eyes” the Red is the “sense” and the smaller white one is the “touch” for the attack anim.

    I can aggro with the eyes sensor, but not the Sense sensor.

    The current setup I have, the two aggro sensors (eyes, sense) both have the same FormVariable, because I figured, if you could trigger one, you could trigger both. I don’t know how to set up/use Audio sensors, I figured visual would work. The Eyes Sensor has a horizontal angle of 136 with LOS required, while the Sense Sensor has a 360 with no LOS required. I’ve been trying to get this to work for a while. Now here’s the strange part. If I Cut/remove the “eyes” Detector from the BT, I can aggro with the Sense Sensor.

    Should I just learn how to set up audio sensors? or is it possible to get this working with multiple visual sensors.
    If it’s needed, here’s my BT XML

    <behaviortree version="1.1" repeatuntil="" name="Zombie1"><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any"><detect sensor=""close"" repeatuntil="running" name="ATKRange" entityobjectvariable="varTouch" aspectvariable="" aspectobjectvariable="" aspect=""aSurvivor"" /><detect sensor=""sense"" repeatuntil="running" name="Sense" entityobjectvariable="varSeen" aspectvariable="" aspectobjectvariable="" aspect=""aSurvivor"" /><detect sensor=""eyes"" repeatuntil="running" name="See" entityobjectvariable="varSeen" aspectvariable="" aspectobjectvariable="" aspect=""aSurvivor"" /><selector usepriorities="False" repeatuntil="" name="Is Survivor seen?"><constraint repeatuntil="" priority="" name="No" constraint="varSeen == null"><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any"><mecparam valueexpression="0.0" repeatuntil="" parametertype="float" parametername="Atk" name="ATK = 0" damptime="0" /><waypointpatrol waypointsetvariable="PatrolRoute" waypointactiontype="patrol" traversetype="loop" traverseorder="forward" repeatuntil="" pathtargetvariable="" name="Walk" movetargetvariable="nextWP"><move turnspeed="" repeatuntil="" name="move to WP" movetarget="nextWP" movespeed="1" facetarget="" closeenoughdistance="" closeenoughangle="" /></waypointpatrol><animate repeatuntil="" name="Walk" animationstate="Walk" /></parallel></constraint><constraint repeatuntil="" priority="" name="Yes" constraint="varSeen != null"><selector usepriorities="False" repeatuntil="running" name="Is Survivor within attack range?"><constraint repeatuntil="" priority="" name="Yes" constraint="varTouch != null"><move turnspeed="" repeatuntil="" name="Face" movetarget="" movespeed="" facetarget="varSurvivor" closeenoughdistance="" closeenoughangle="" /><animate repeatuntil="" name="Attack" animationstate="Atk" /></constraint><constraint repeatuntil="" priority="" name="No" constraint="varTouch == null"><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any"><animate repeatuntil="" name="Run" animationstate="Run" /><mecparam valueexpression="0.0" repeatuntil="" parametertype="float" parametername="Atk" name="Atk = 0" damptime="0" /><move turnspeed="" repeatuntil="" name="Move to Survivor" movetarget="varSeen" movespeed="4" facetarget="" closeenoughdistance="" closeenoughangle="" /></parallel></constraint></selector></constraint></selector></parallel></behaviortree>
    
    • This topic was modified 6 months ago by  OMGItzGnaR.
    • This topic was modified 6 months ago by  OMGItzGnaR.
    #34417

    cycro
    Participant

    Hey there.

    I’ve been having problems with trying to achieve the same thing, too. Did you solve this? My AI can detect on both visual sensors just fine and then jumps into the “attack” behavior tree - but it just repeats it’s walk animation and gets stuck. According to the debugger, the “move” part is the problem - but the first sensor I use redirects into the same behavior tree - and that works just fine.

    No clue on how to solve this.

    #34419

    prime
    Keymaster

    Not sure why we didn’t see the first post from @OMGItzGnaR back in July - sorry about that.

    I think the original issue was occurring because the same variable is used for eyes and sense, and that variable is an entry condition for aggro. So when either sensor detects, the same result happens. The fix would be to use separate variables and trigger behavior based on which one is activated.

    @cycro - I don’t know what your issue might be. Are you saying your Move node is failing, or is there something else happening?

    #34420

    RubenVargas
    Participant

    Ok first, sorry for the bad english.

    Im not sure if this is what you want, but i think you need to use some constraint nodes, so you can know when the player is on range of one or two sensors.

    You should use constraint nodes, use different mount point variable on every sensor and check what is the status of every one.

    In the constraint you can check if both or one sensor is trigger using the mountVariable (or any other detect variable) like this:

    Constraint: mountPointVariable1 != null && mountPointVariable2 != null
    This will activate the constraint when both are on visual range

    Constraint: mountPointVariable1 != null
    This will activate the constraint when the first sensor is on range

    Constraint: mountPointVariable2 != null
    This will activate the constraint when the second sensor is on range

    Constraint: mountPointVariable1 == null && mountPointVariable2 != null
    This will activate the constraint when the first sensor (your eyes) is out of range, but the second one (your sense) is on range.

    Constraint: mountPointVariable1 == null && mountPointVariable2 == null
    This will activate the constraint when both are NOT on visual range

    If you do this, you can have a different tree of actions for every case :)

    #34421

    cycro
    Participant

    Hello @prime. Glad you’re taking some time for this, it’s really bugging me :p

    The move node does not appear to be failing. It’s green alright, but even though it works fine for the first detector, as soon as it has been triggered by the second detector, the AI just gets stuck and loops its walk animation. As soon as I enter the front detector again however, it works fine.

    This is my BT:

    BT

    As you can see, I have 3 detectors set up. “Detect far” is the front detector (looking only straight away from the eyes), “Detect Far - Back” is the detector with a smaller view size - and “CanAttack” plays an attack animation as soon as the AI gets close enough to the player.

    Now, “Detect Far” and “CanAttack” work flawlessly, but the “Detect Far - Back” one has issues. You can see in the screenshot that the “Detect Far - Back” sensor properly had the routine jump into the “constraint (follow player)” and it does seem to work, but the AI is just stuck. When I creep up on it from behind it just repeats the walk animation I have set up and doesn’t even turn around - but it did detect me fine.

    @RubenVargas

    This is pretty much how my BT has been set up btw.

    • This reply was modified 1 month, 2 weeks ago by  cycro.
    #34423

    RubenVargas
    Participant

    I think I know the problem. You are using a selector, and it will not go to the next node until every child succeed, but your move animation is looping (as it should be).

    Just replace the selector for a parallel, and make sure your constraints do not allow the other one to run at the same time :).

    #34424

    cycro
    Participant

    Hmm, but within the constraint, there is a parallel already and it seems it properly jumped into it. After all it works fine with one detector and not with the other, which is set up with the same logic to jump into that tree. So this didn’t work sadly.

    • This reply was modified 1 month, 2 weeks ago by  cycro.
    #34433

    prime
    Keymaster

    It’s likely that the Parallel running your Move node is set to “Succeed on All”. You can see that your Detect and Move node have succeeded but your Animate is still playing (and will continue repeating forever as long as you have a looping animation.)

    (1) I suspect you don’t really want the Audio Detect in that parallel
    (2) You probably want the parallel to succeed on any

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

You must be logged in to reply to this topic.