News Forums Troubleshooting Help: Following then attacking when close enough

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

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #8217

    morsavita
    Participant

    Hello sorry I am new to rain and unity and am enjoying using both but am really stuck and could use some help. I got the basics working and have the lizard wandering then following way-points until he sees the player, and then he will take off following the player while the enemy has line of sight… check working great using mecanim. Now I am trying to implement just a little more functionality and having major problems. I would like to make it so the lizard enemy chases the player around until he gets within range then change mecanim state to attack and speed back to 0. So I don’t have to time out attacks I am testing with a basic dance anim upon melee radius detection. I have 2 sensor both visual applied to the lizard and looking for the same aspect of player. The problem seems to be with the nested detector it gets to it but does not seems to find the constraints after Both of the detects are set on repeat forever. It seems to successfully drop down into the meleeDetect and the variable appears in the memory as null but it does not drop into the dance == null constraint. Oddly enough if I change the melee detector to repeat until success the lizard will quit patrolling while I am out of melee range not finding the dance null constraint but when I enter the meleeSensor Range he does sense it and begins to dance. But when it is on repeat forever the enemy never detects when the player enters melee range. Thank you for anyone’s help into this matter it should just be something simple I am over looking.

    #8218

    morsavita
    Participant

    Whoops

    #8331

    OpposableJames
    Participant

    I’m having the same problem with nesting constraints under a selector. If have two different sensor radii set up, one for sight and one for weapon range. In both cases the variables for the targets are being correctly set. However when I get to this stage:

    sel
     - con ( attackTarget != null )
       - move ( attackTarget )
     - con ( senseTarget != null )
       - move ( senseTarget )
     - move ( wanderTarget )

    It’s always falling through to the last move, despite attackTarget/senseTarget being active in the AI’s memory

    #8388

    prime
    Keymaster

    @morsavita - it might be helpful if you were to upgrade to RAIN 2.0.10, save your BT out as xml, and then post it here. I’m having trouble following your explanation.

    @OpposableJames - I’d need more info. The constraints must be failing for the selector to fall through, so either the variables are null, or there is a problem in the way the expressions have been entered into the constraints.

    #8424

    morsavita
    Participant

    Thank you hopefully this works and formats correctly. If not that picture is the right one and can be zoomed in on with ctrl and the mouse wheel. Very sorry for the inconvenience sir, and thank you for the help when i better .

    <?xml version="1.0"?>
    -<behaviortree name="basicWanderFollowMecanim" repeatuntil="" version="1.1">
    -<parallel name="root" repeatuntil="" fail="any" succeed="all" tiebreaker="fail">
    <detect name="detect" repeatuntil="running" aspect=""player"" aspectobjectvariable="" aspectvariable="" entityobjectvariable="spotted" sensor=""visualSensor""/>
    -<selector name="selector" repeatuntil="" usepriorities="False">
    -<constraint name="constraint" repeatuntil="" constraint="spotted != null" priority="">
    <detect name="meleeDetect" repeatuntil="running" aspect=""player"" aspectobjectvariable="" aspectvariable="" entityobjectvariable="dance" sensor=""danceSensor""/>
    -<selector name="selector" repeatuntil="" usepriorities="True">
    -<constraint name="constraint" repeatuntil="" constraint="dance != null" priority="">
    -<parallel name="parallel" repeatuntil="" fail="any" succeed="all" tiebreaker="fail">
    <mecparam name="mecparam" repeatuntil="" damptime="0" parametername="dance" parametertype="boolean" valueexpression="True"/>
    <mecparam name="mecparam" repeatuntil="" damptime="0" parametername="Speed" parametertype="float" valueexpression="0"/>
    </parallel>
    </constraint>
    -<constraint name="constraint" repeatuntil="" constraint="dance == null" priority="">
    <move name="move" repeatuntil="" closeenoughangle="" closeenoughdistance="1" facetarget="" movespeed="2" movetarget="spotted" turnspeed=""/>
    </constraint>
    </selector>
    </constraint>
    -<constraint name="constraint" repeatuntil="" constraint="spotted == null" priority="">
    -<parallel name="parallel" repeatuntil="" fail="any" succeed="all" tiebreaker="fail">
    -<waypointpatrol name="waypointpatrol" repeatuntil="" movetargetvariable="moveTarget" pathtargetvariable="" traverseorder="forward" traversetype="loop" waypointactiontype="patrol" waypointsetvariable=""Waypoint Route"">
    <move name="move" repeatuntil="" closeenoughangle="" closeenoughdistance="" facetarget="" movespeed="" movetarget="moveTarget" turnspeed=""/>
    </waypointpatrol>
    </parallel>
    </constraint>
    </selector>
    </parallel>
    </behaviortree>
    #8454

    OpposableJames
    Participant

    Here’s mine:

    -<behaviortree name="Cutter" repeatuntil="" version="1.1">
    -<sequencer name="sequencer" repeatuntil="" usepriorities="False">
    <action name="action" repeatuntil="" classname="ChooseWanderLocation" namespace="(global)" parameters="" parametervalues="" priority=""/>
    -<parallel name="parallel" repeatuntil="running" priority="" fail="all" succeed="any" tiebreaker="succeed">
    <detect name="Detect Enemy" repeatuntil="running" aspect=""Crew"" aspectobjectvariable="" aspectvariable="" entityobjectvariable="enemyTarget" sensor=""Eyes""/>
    <detect name="Detect Attack Target" repeatuntil="running" aspect=""Crew"" aspectobjectvariable="" aspectvariable="" entityobjectvariable="attackTarget" sensor=""Weapon""/>
    -<sequencer name="checkWanderTarget" repeatuntil="" usepriorities="False">
    <action name="action" repeatuntil="" classname="WaypointReachedTest" namespace="(global)" parameters="" parametervalues="" priority=""/>
    <action name="action" repeatuntil="" classname="ChooseWanderLocation" namespace="(global)" parameters="" parametervalues="" priority=""/>
    </sequencer>
    -<selector name="selector" repeatuntil="" usepriorities="False">
    -<constraint name="constraint" repeatuntil="" priority="" constraint="attackTarget != null">
    -<parallel name="Move and attack" repeatuntil="" fail="any" succeed="all" tiebreaker="fail">
    <move name="Look at attackTarget" repeatuntil="" closeenoughangle="" closeenoughdistance="" facetarget="attackTarget" movespeed="1" movetarget="attackTarget" turnspeed=""/>
    <action name="Attack" repeatuntil="" classname="Attack" namespace="(global)" parameters="" parametervalues=""/>
    </parallel>
    </constraint>
    -<constraint name="constraint" repeatuntil="" priority="" constraint="enemyTarget != null">
    <move name="move" repeatuntil="" closeenoughangle="" closeenoughdistance="" facetarget="" movespeed="8" movetarget="enemyTarget" turnspeed=""/>
    </constraint>
    <move name="move" repeatuntil="" priority="" closeenoughangle="" closeenoughdistance="" facetarget="" movespeed="8" movetarget="wanderTarget" turnspeed=""/>
    </selector>
    </parallel>
    </sequencer>
    </behaviortree>
    #8472

    prime
    Keymaster

    ugh. Looks like there are some import/export issues with the xml. We’ll get that fixed.

    #8480

    prime
    Keymaster

    @morsavita - some things I notice about your BT right away:

    1) Your 2 detect nodes are redundant. The first one detects the player using any sensor. The second one does the same. If the player is ever not detected, the second one won’t even run because it is inside a constraint
    2) You have priorities turned on for your 2nd Selector, but you aren’t using them. Turn that off.
    3) Your second constraint (dance == null) will never happen, because whenever dance == null, spotted is also null and the BT would have failed out at the outer constraint.

    #8482

    prime
    Keymaster

    @OpposableJames -

    1) I don’t think your parallel works the way you want it to. It is set to succeed on Any, which means that if your checkWanderTarget succeeds the Parallel will reset. At a minimum, this will cause jittery movement.
    2) If checkWanderTarget does not succeed, then it will never run again (not set to repeat)

    The constraints in the selector look fine. I suspect something else is going on there, and the problem has more to do with 1 or 2 or the general structure.

    #8492

    morsavita
    Participant

    Thanks Prime,
    That all makes sense so please excuse my noobness but how do I fix it. The idea was so the (dance == null) would be dependent on being (spotted == null) The idea is once the enemy spots its target to move to the target till in meeleRange then attack or to have nested decisions. I am just using dance to error test atm. The visual sensor is set to a distance of 20 and the danceSensor is set to only 10.

    1) How do I fix the redundant detector nodes. I don’t understand quite what I did wrong here. I wanted the first detect to use the “visualSensor” to detect the player. “visualSensor” is the renamed sensor I have attached to the enemy(not the best name but it made sense to be his fov). The sensor do seem to work I can see the value change from null to player in the mind settings during run time when I enter the appropriate range. The problem is when the player is detected it is not dropping into the constraints it just stays on the detect node and goes in idle animation.

    2) Whoops I unchecked that it was from me trying to fix things on my own never good ><

    Thanks again prime when I get this figured out a little more I will help pay it forward and help others on the forum this does seems like amazing software just has a bit of a learning curve.

    #8497

    morsavita
    Participant

    Just an edit when I do leave the range of both detectors they get set back to false and then the AI will start follow the waypoints again.

    #8501

    prime
    Keymaster

    Oh, sorry - the BT xml didn’t import correctly for me and I lost the fact that you specified different sensors for those two.

    Any chance you can send a project over so we can help debug?

    #8503

    morsavita
    Participant

    No prob prime its OK. When I get home from work tonight I will send it over, thank you very much for all your help I can’t even imagine how busy you must be.

    #8607

    morsavita
    Participant

    It was a bigger file that I expected to many extras I imported ><. So I posted it to a google drive and e-mailed jester the link thanks again for all of your help.

    #8926

    morsavita
    Participant

    Hey Prime,
    I am still unable to figure this out and have even tried some different bt builds this is getting very frustrating. If someone could help point me in the right direction that would be very nice. Even if you can’t help fix my original project could someone post an example of a working bt. I am trying to have my enemy patrol or follow depending if the enemy is spotted or not. I got this example to work using the tuts no problem. Now I would like to add more functionality. I would like to make the enemy detect when the player is within certain ranges. When within melee range I would like the enemy to start attacking. So basically I would like to set up nested behaviors like if the player is spotted and in melee range attack if only spotted then follow him and if neither then patrol. If anyone can help me please I would really appreciate it.

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic.