News Forums RAIN General Discussion and Troubleshooting Timer keeps restarting

This topic contains 2 replies, has 2 voices, and was last updated by  Blizzard_jedi 10 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37781

    Blizzard_jedi
    Participant

    Hello! I’m currently trying to create my own Patrol-n-Chase behavior. The problem is that I have a timer, that runs forever.

    I tried a lot to find a solution in the internet, but failed. The timer is set to pause for 1s. When the code hits it, the running process stucks in this timer forever. If I change the amount of time to pause to 0.1s, the timer manages to run successfully. But it doesn’t succeed right on the first run - it fails a number of times and only then succeeds. So it really seems to me, that the timer keeps restarting over and over, so that it will never have an opportunity to run that long (for 1s).

    I have no ideas, what causes the timer to restart. Help me, please. Here’s the serialized behavior tree, that I’m currently working on:

    <scriptableobject version="1.2" type="RAIN.BehaviorTrees.BTAsset"><fields><field value="<behaviortree version="1.1" repeatuntil="" name="MummyPatrolAndFollow" debugbreak="False"><parallel tiebreaker="fail" succeed="any" repeatuntil="" name="root" fail="any" debugbreak="False"><detect sensor=""Eyes"" repeatuntil="running" name="detect far" matchtype="best" entityobjectvariable="seenFar" debugbreak="False" consistent="True" aspectvariable="" aspectobjectvariable="" aspect=""PlayerCharacter"" /><detect sensor=""CloseSense"" repeatuntil="running" name="detect close" matchtype="best" entityobjectvariable="seenClose" debugbreak="False" consistent="True" aspectvariable="" aspectobjectvariable="" aspect=""PlayerCharacter"" /><constraint repeatuntil="" name="seenClose != null" debugbreak="False" constraint="seenClose != null"><action repeatuntil="" parametervalues="" parameters="" namespace="(global)" name="KillPlayer" debugbreak="False" classname="KillPlayer" /></constraint><selector usepriorities="False" repeatuntil="" name="Patrol or Follow" debugbreak="False"><constraint repeatuntil="" priority="" name="seenFar == null && !Chasing" debugbreak="False" constraint="seenFar == null && !Chasing"><parallel tiebreaker="fail" succeed="all" repeatuntil="" name="Patrol" fail="any" debugbreak="False"><mecparam valueexpression="1" repeatuntil="running" parametertype="float" parametername="speed" name="walk" debugbreak="False" damptime="0.3" /><waypointpatrol waypointsetvariable="MummyRoute1" waypointactiontype="patrol" traversetype="loop" traverseorder="forward" repeatuntil="" pathtargetvariable="" name="waypointpatrol" movetargetvariable="nextRoutePoint" debugbreak="False"><move turnspeed="" repeatuntil="" name="patrol" movetarget="nextRoutePoint" movespeed="" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /></waypointpatrol></parallel></constraint><constraint repeatuntil="" priority="" name="seenFar != null" debugbreak="False" constraint="seenFar != null"><parallel tiebreaker="succeed" succeed="any" repeatuntil="" name="Follow" fail="any" debugbreak="False"><mecparam valueexpression="1" repeatuntil="running" parametertype="float" parametername="speed" name="walk" debugbreak="False" damptime="0.3" /><move turnspeed="" repeatuntil="" name="Follow" movetarget="seenFar" movespeed="" facetarget="" debugbreak="False" closeenoughdistance="0.5" closeenoughangle="" /><expression returnvalue="success" repeatuntil="" name="Chasing = true" expression="Chasing = true" debugbreak="False" /></parallel></constraint><constraint repeatuntil="" priority="" name="seenFar == null && Chasing" debugbreak="False" constraint="seenFar == null && Chasing"><parallel tiebreaker="succeed" succeed="any" repeatuntil="" name="Wait" fail="any" debugbreak="False"><mecparam valueexpression="0" repeatuntil="running" parametertype="float" parametername="speed" name="idle" debugbreak="False" damptime="0.3" /><sequencer usepriorities="False" repeatuntil="" name="sequencer" debugbreak="False"><timer waitforsec="0" returnvalue="success" priority="" name="timer" debugbreak="False" /><expression returnvalue="success" repeatuntil="" priority="" name="Chasing = false" expression="Chasing = false" debugbreak="False" /></sequencer></parallel></constraint></selector></parallel></behaviortree>" type="System.String" id="treeData" /><field type="System.Array" id="treeBindings" elementtype="System.String" /></fields><references /></scriptableobject>
    #37817

    prime
    Keymaster

    I haven’t had a chance to look at your BT, but every time I’ve seen this comment about timers on our forums (there have been many) it happens because some parent of the timer is restarting. Usually that’s a parallel that is set to fail or succeed on any, and some child of the parallel is doing so.

    #38092

    Blizzard_jedi
    Participant

    prime, The idea, you expressed in your post, really helped me, thank you!

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

You must be logged in to reply to this topic.