News Forums Search Search Results for 'constraint'

Viewing 15 results - 1 through 15 (of 326 total)
  • Author
    Search Results
  • #40238

    Lutzelodeon
    Participant

    Now this is not my biggest problem.
    The AI is detecting the Player and go to the position.
    If the AI can’t see the Player anymore it should use the Waypoint Network.
    The only thing the AI is doing then is just spinning on one point (Close enough radius is increased etc.).

    Here is my Behavior Tree:

    <behaviortree version=”1.1″ repeatuntil=”” name=”SimpleAI” debugbreak=”False”>
    <parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” name=”root” fail=”any” debugbreak=”False”>
    <detect sensor=”"eyes"” repeatuntil=”running” name=”eyes” matchtype=”best” entityobjectvariable=”varHero” debugbreak=”False” consistent=”False” aspectvariable=”” aspectobjectvariable=”” aspect=”"Player"” />
    <selector usepriorities=”False” repeatuntil=”” name=”selector” debugbreak=”False”>
    <constraint repeatuntil=”” priority=”” name=”constraint” debugbreak=”False” constraint=”varHero == null && !isSearching”>
    <parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” name=”parallel” fail=”any” debugbreak=”False”>
    <waypointpatrol waypointsetvariable=”PatrolRoute” waypointactiontype=”patrol” traversetype=”pingpong” traverseorder=”forward” repeatuntil=”” pathtargetvariable=”” name=”Walk” movetargetvariable=”nextWaypoint” debugbreak=”False”>
    <move turnspeed=”” repeatuntil=”” name=”move” movetarget=”nextWaypoint” movespeed=”” facetarget=”” debugbreak=”False” closeenoughdistance=”” closeenoughangle=”” />
    </waypointpatrol>
    <mecparam valueexpression=”0.5″ repeatuntil=”running” parametertype=”float” parametername=”AnimSpeed” name=”mecparam” debugbreak=”False” damptime=”0.15″ />
    </parallel>
    <random repeatuntil=”running” name=”random” debugbreak=”False”>
    <sequencer weight=”” usepriorities=”False” repeatuntil=”” name=”sequencer” debugbreak=”False”>
    <timer waitforsec=”15″ returnvalue=”success” priority=”” name=”timer” debugbreak=”False” />
    <audio waituntildone=”False” repeatuntil=”” priority=”” name=”audio” forcestoponexit=”False” delay=”0″ debugbreak=”False” audiosource=”PatrolSounds” />
    </sequencer>
    <sequencer weight=”” usepriorities=”False” repeatuntil=”” name=”sequencer” debugbreak=”False”>
    <timer waitforsec=”15″ returnvalue=”success” priority=”” name=”timer” debugbreak=”False” />
    <audio waituntildone=”False” repeatuntil=”” priority=”” name=”audio” forcestoponexit=”False” delay=”0″ debugbreak=”False” audiosource=”PatrolSounds2″ />
    </sequencer>
    </random>
    </constraint>
    <constraint repeatuntil=”” priority=”” name=”constraint” debugbreak=”False” constraint=”varHero != null”>
    <expression returnvalue=”evaluate” repeatuntil=”” name=”expression” expression=”isSearching = true” debugbreak=”False” />
    <sequencer usepriorities=”False” repeatuntil=”” name=”sequencer” debugbreak=”False”>
    <parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” priority=”” name=”parallel” fail=”any” debugbreak=”False”>
    <audio waituntildone=”True” repeatuntil=”” name=”audio” forcestoponexit=”False” delay=”0″ debugbreak=”False” audiosource=”Parasite_L_Starkie” />
    <move turnspeed=”” repeatuntil=”” name=”move” movetarget=”varHero” movespeed=”” facetarget=”” debugbreak=”False” closeenoughdistance=”” closeenoughangle=”” />
    <mecparam valueexpression=”1″ repeatuntil=”running” parametertype=”float” parametername=”AnimSpeed” name=”mecparam” debugbreak=”False” damptime=”0.15″ />
    </parallel>
    </sequencer>
    </constraint>
    <constraint repeatuntil=”” priority=”” name=”constraint” debugbreak=”False” constraint=”varHero == null && isSearching”>
    <parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” name=”parallel” fail=”any” debugbreak=”False”>
    <waypointpath waypointsetvariable=”Wander” waypointactiontype=”path” traversetype=”pingpong” traverseorder=”forward” repeatuntil=”” pathtargetvariable=”"varMoveTo"” name=”waypointpath” movetargetvariable=”varNextWander” debugbreak=”False”>
    <move turnspeed=”” repeatuntil=”” name=”move” movetarget=”varNextWander” movespeed=”” facetarget=”” debugbreak=”False” closeenoughdistance=”” closeenoughangle=”” />
    </waypointpath>
    <mecparam valueexpression=”0.75″ repeatuntil=”running” parametertype=”float” parametername=”AnimSpeed” name=”mecparam” debugbreak=”False” damptime=”0.15″ />
    <sequencer usepriorities=”False” repeatuntil=”” name=”sequencer” debugbreak=”False”>
    <timer waitforsec=”30″ returnvalue=”success” priority=”” name=”timer” debugbreak=”False” />
    <expression returnvalue=”evaluate” repeatuntil=”” priority=”” name=”expression” expression=”isSearching = false” debugbreak=”False” />
    </sequencer>
    <random repeatuntil=”” name=”random” debugbreak=”False”>
    <sequencer weight=”” usepriorities=”False” repeatuntil=”” name=”sequencer” debugbreak=”False”>
    <timer waitforsec=”5″ returnvalue=”success” priority=”” name=”timer” debugbreak=”False” />
    <audio waituntildone=”False” repeatuntil=”” priority=”” name=”audio” forcestoponexit=”False” delay=”0″ debugbreak=”False” audiosource=”SearchSounds” />
    </sequencer>
    <sequencer weight=”” usepriorities=”False” repeatuntil=”” name=”random” debugbreak=”False”>
    <timer waitforsec=”5″ returnvalue=”success” priority=”” name=”timer” debugbreak=”False” />
    <audio waituntildone=”False” repeatuntil=”” priority=”” name=”audio” forcestoponexit=”False” delay=”0″ debugbreak=”False” audiosource=”SearchSounds2″ />
    </sequencer>
    </random>
    </parallel>
    </constraint>
    </selector>
    </parallel>
    </behaviortree>

    #40114

    In reply to: Audio Sensor issue


    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.

    #40110

    In reply to: RAIN Mecanim help


    RAINLover
    Participant

    Hey I think I found a small bug. With sequencer, it stops when the first constraint returns false. Anyway, this script is exactly what I was looking for. A simple hunt to go to the last known location before resuming the search.

    root
       parallel (succeed: any, fail: any, tie breaker: fail)
          detect (repeat: forever, form variable: myTarget)
          sequencer //SHOULD BE SELECTOR!!!
             constraint (constraint: myTarget == null)
                waypoint patrol
                   move
             selector
                constraint (constraint: myTarget != null)
                   parallel (succeed: any, fail: any, tie breaker: fail)
                      expression (repeat: forever, expression: myTargetPosition = position(myTarget))
                      move (move target: myTarget)
                constraint (constraint: myTarget == null)
                   move (move target: myTargetPosition)
                   expression (expression: debug("Lost my target"), returns: success)
    • This reply was modified 1 month, 1 week ago by  RAINLover.
    #40091

    In reply to: Audio Sensor issue


    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 1 month, 2 weeks ago by  kilfeather94.
    • This reply was modified 1 month, 2 weeks ago by  kilfeather94.
    #40078

    In reply to: Audio Sensor issue


    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 1 month, 1 week ago by  Sigil. Reason: added repeat to detect node
    #40060

    klawd
    Participant

    (Is it normal that I can’t edit the original post anymore?)
    I have actually noticed that the detect node never assign the variable… here’s how the node is configured:


    Here the door entity, and the AI rig/sensor:



    Am I doing something wrong? Shouldn’t the detect node, use the sensor to detect the door entity and set the variable to trigger the constraint nodes?

    EDIT2: I noticed the door Entity Rig had no form, so I put the door gameobject in it, but the detect node still doesn’t detect the door.

    • This reply was modified 1 month, 2 weeks ago by  klawd.
    • This reply was modified 1 month, 2 weeks ago by  klawd.

    klawd
    Participant

    First I want to congratulate, and thank, the developers for such a great product. I love what you are doing with Squad and Sentio and that you are keeping RAIN free. You guys rocks.

    My problem:
    I’m working on a game in my free time, and I opted to use RAIN because I needed a tool able to make Navigation Meshes at runtime (maps are generated procedurally). I then made my player controlled character use an AI rig to move, by getting its move variable from a raycast hit.
    The complications started when I decided to use a Sensor to detect obstacles (ie. a door equipped with an Entity component). The idea is to make the character stop before a door/obstacle, that’s been put dynamically on the NavMesh, and not keep running on its collider. The NavMesh generation filtrates the layer containing the doors, so that once the door collider is removed (ie. the door opened) the character is able to walk in the next room.

    I thought the BT like this:
    *root [parallel]
    -detect (on repeat forever) with player’s sensor and door’s aspect
    -selector (on repeat forever)
    —-constraint on door variable (== null)
    ——move to raycast hit point
    —-constraint on door variable (!= null)
    ——-move to character to the player gameobject position (aka stop where you sensed the door)

    If I click in the area in front of the door, the character moves there, and the door variable gets fired correctly (the second move action is never triggered though)
    But if I click in the next room, and there’s a closed door in between, the character go hugs this door’s collider while continuing to try and walk past it…

    I suspect that I’m using RAIN in a unorthodox manner, and not for what it was thought for, but the NavMesh generation at runtime makes RAIN essential to my project. I do plan on using RAIN also for the AIs of the game’s enemies component, and I would like to integrate it with everything else.
    Hope you guys can give me some directions.

    • This topic was modified 1 month, 2 weeks ago by  klawd.

    Ibrahim
    Participant

    Hello,

    I learned to build simple BTs that do simple tasks. But now when I tried to use BTs for my AI characters in the project I found difficulty building the BTs that will execute the behavior I wish to have. I have watched tutorials (all are very basic examples), and also read all the RAIN WIKI but still not able to build what I want.

    My game is about fire fighting: For instance, I want my AI (Team Leader) to check if the game started or not, once it started, he should query the GameController script about the first situation to handle, once he get this answer, he should send a message to all Firefighters to go to the fire truck, and once they are all inside it, the fire truck should move to the situation, and then he should command them to line up in front of the Truck, and so forth.. querying about the game from the game environment, receive and send information to other AIs and do some actions.

    Every other AI should also has its own BT, that controls his actions, receiving messages, doing actions, sensing and sending messages.

    I have started with the following BT for the Team Leader, but I it really seems weak and not working as expected (because of not understanding the nodes rules and how the sequence follow from one step to the next).

    <behaviortree version="1.1" repeatuntil="" name="FF_TL_BT" debugbreak="False"><sequencer usepriorities="False" repeatuntil="" name="TL_root" debugbreak="False"><constraint repeatuntil="" priority="" name="Game started? and there is at least one situation to handle?" debugbreak="False" constraint="gameStarted == true && numberOfSituations > 0"><constraint repeatuntil="" name="Far from situation?" debugbreak="False" constraint="distanceToSituation > 50"><sequencer usepriorities="False" repeatuntil="" name="sequencer" debugbreak="False"><action repeatuntil="" priority="" parametervalues="" parameters="" namespace="(global)" name="Send Message to FFs to go to FF Truck" debugbreak="False" classname="SendMessageToFFs" /></sequencer><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any" debugbreak="False"><move turnspeed="" repeatuntil="" name="Move to my door in fire truck" movetarget="myDoor" movespeed="3" facetarget="myDoor" debugbreak="False" closeenoughdistance="" closeenoughangle="" /><animate repeatuntil="" name="animate" debugbreak="False" animationstate="Locomotion.WalkRun" /></parallel><constraint repeatuntil="" name="constraint" debugbreak="False" constraint="!ffDetector.active"><action repeatuntil="" parametervalues="" parameters="" namespace="(global)" name="Send message to FF Truck to go to currentsituation" debugbreak="True" classname="SendMessageToFFTruck" /></constraint></constraint></constraint></sequencer></behaviortree>

    Any help will be appreciated.

    #39995

    In reply to: RAIN Mecanim help


    Sigil
    Keymaster

    We have an expression function to help with that, called position.

    Essentially you will need to record his position while you are chasing him, so that in the event you lose your target (but still have his position) you can head to it. I’d have to look at the overall behavior tree, but in general you can do something like this:

    root
       parallel (succeed: any, fail: any, tie breaker: fail)
          detect (repeat: forever, form variable: myTarget)
          selector
             constraint (constraint: myTarget == null)
                waypoint patrol
                   move
             selector
                constraint (constraint: myTarget != null)
                   parallel (succeed: any, fail: any, tie breaker: fail)
                      expression (repeat: forever, expression: myTargetPosition = position(myTarget))
                      move (move target: myTarget)
                constraint (constraint: myTarget == null)
                   move (move target: myTargetPosition)
                   expression (expression: debug("Lost my target"), returns: success)

    I wrote it a bit differently then your original, but the general idea is that you need to handle the failure case of your chasing. Once you start chasing (and recording their position) if you fail it means you lost the target, so you can put a selector around that and handle the failure by continuing to head to the position. If you ever detect the target again, it’ll hit the constraint and fail and start at the top again.

    As for your second issue, what would you like the AI to do instead of heading back to the original waypoints? If you wanted them to search around for the player instead, you could have a second waypoint network of search spots that he starts to follow, for instance. Whatever it is, this would end up being the success case for reaching the players last position, so where I have the debug “Lost my target”, you could put a sequencer, or another patrol setup, or have them do a dance, or anything you like.

    • This reply was modified 1 month, 1 week ago by  Sigil. Reason: fixed a bug in the behavior tree (per post below)
    #39977

    In reply to: RAIN Mecanim help


    svalero1124
    Participant

    Thanks so much Sigil! Everything you’ve told me so far has worked flawlessly! i managed to get the mecanimMotor to do all the moving now and it works great!

    I have just a few more questions regarding the behavior tree. As i have it now my NPC patrols and when he detects the player he runs after them which is perfect! BUT if the player takes a step to the left or right or just ‘S’ keys backwards the NPC loses sight of him, for just a second, and then chases him again. So what that ends up doing is making him stutter from a run to a walk back to a run very quickly but it’s heavily noticeable and he will keep doing it until you turn a corner or he finally catches you.

    My tree looks like this. The first constraint is just his normal patrol route with a random idle added to it.

    1) constraint(varPlayer==null) just patrols
    2) constraint(varPlayer!=null) goes into constraint #3
    3)constraint(varMelee==null) chases player until he’s in melee range
    4)constraint(varMelee!=null) some attack animation haven’t got that far yet

    And then regarding his waypoint markers, when my NPC reaches any waypoint marker, because of how my map is laid out, most of them are sharp 90 degree angles. My NPC will just turn very quickly towards the next point. What I’m wondering is if there’s a way to tell him to take the turn slightly slower. Kind of like a transition to turning instead of just facing north and then suddenly looking east and having no delay to it.

    #39941

    In reply to: Sensor not working


    Sigil
    Keymaster

    It’s not a waste, no worries.

    So it looks like you have your constraints set to repeat forever, which will block any chance of the constraint failing, keeping it from moving past the first one.

    I imagine the reason you added the repeat is that your guy got stuck somewhere in the tree after doing something once (like attacking). Check your parallel node at the top and make sure the Fail and Succeed options are both set to Any. The tie breaker won’t matter in that case.

    #39938

    In reply to: Sensor not working


    Cubiboy
    Participant

    No I have an other problem… if the Enemy sees me and attacks me and I run away he rans towards me but if I’m too far away his animation stops and doesn’t run the “enemy not found” constraint…
    https://www.dropbox.com/s/2tyxpvfdibj0wbg/Screenshot%202016-01-22%2020.54.41.png?dl=0

    Thanks a lot for your time you waste for me!

    #39933

    In reply to: Sensor not working


    Sigil
    Keymaster

    The Entity and Aspect look good, let’s take a look at your sensors instead. I’m assuming you have two visual sensors, one named closeSensor and one named nearbySensor (maybe?).

    Given the constraint that is failing, it is likely the nearbySensor that is keeping it from continuing (from your first post, varHeroNearby is likely null). So perhaps a quick screenshot of both sensors so we can see what they look like.

    #39927

    In reply to: Sensor not working


    Sigil
    Keymaster

    Can you post a screenshot of your behavior tree?

    When you said the constraint has an error, do you mean that the expression is red or do you mean you are getting an exception in your console?

    #39926

    Cubiboy
    Participant

    Hello

    I try to finish my AI and setup 2 visual sensors to detect. To my Player I attached a Entity. In BT I wrote the Aspect and the
    sensor with quotes but it’s still not working. Also in a constraint happens an error: varHeroNearby != null && myHealth > 0

    Have you an idea to fix it?

    Thank you very much!

Viewing 15 results - 1 through 15 (of 326 total)