News › Forums › RAIN › Sample Projects, How To, and Code › Solved: Reset action after success
This topic contains 0 replies, has 1 voice, and was last updated by RinAldrin 2 months, 2 weeks ago.
-
AuthorPosts
-
July 27, 2022 at 8:28 pm #38741
Basically what I am trying to do is I have a NPC who when he sees and enemy he runs away then stops and looks back to see if he is being chased, if he isn’t then he returns to wandering. The problem is that if I have the primary detect set to repeat until success then after he flees he won’t start detecting again because the detect is not repeating now. However if I have it set to repeating forever then as soon as he stops seeing the enemy he instantly forgets as soon as it leaves the visual detector. So ether I need to set it up so that once he is safe it resets the detect so that he starts wandering again or I need to have the detect send the info to a separate var when he sees the enemy and then clear it once he is safe. Is there a way to do this within the UI or do I have to make a script if so where do I start?
EDIT: After toying around more I managed to get it working for those who wish to know how I did it here is the export of the XML file.
<behaviortree version="1.1" repeatuntil="" name="HumanAI" debugbreak="False"> <sequencer usepriorities="False" repeatuntil="" name="root" debugbreak="False"> <parallel tiebreaker="fail" succeed="all" repeatuntil="running" name="parallel" fail="any" debugbreak="False"> <selector usepriorities="False" repeatuntil="running" name="selector" debugbreak="False"> <constraint repeatuntil="" priority="" name="Wander" debugbreak="False" constraint="Enemies == null"> <sequencer usepriorities="False" repeatuntil="" name="sequencer" debugbreak="False"> <parallel tiebreaker="fail" succeed="all" repeatuntil="running" priority="" name="parallel" fail="any" debugbreak="False"> <detect sensor=""Eyes"" repeatuntil="running" name="detect" matchtype="best" entityobjectvariable="Enemies" debugbreak="False" consistent="True" aspectvariable="" aspectobjectvariable="" aspect=""Enemy"" /> <sequencer usepriorities="False" repeatuntil="running" name="sequencer" debugbreak="False"> <action repeatuntil="success" priority="" parametervalues="UmFuZG9tKDQsOCkAdHJ1ZQBIV1A=" parameters="V2FuZGVyRGlzdGFuY2UAU3RheU9uR3JhcGgAV2FuZGVyVGFyZ2V0VmFyaWFibGU=" namespace="" name="action" debugbreak="False" classname="ChooseWanderPosition" /> <move turnspeed="" repeatuntil="" priority="" name="move" movetarget="HWP" movespeed="HSpeed" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> <timer waitforsec="Random(4,8)" returnvalue="success" priority="" name="timer" debugbreak="False" /> </sequencer></parallel></sequencer></constraint> <parallel tiebreaker="fail" succeed="all" repeatuntil="" priority="" name="Check for Enemies" fail="any" debugbreak="False"> <sequencer usepriorities="False" repeatuntil="" name="sequencer" debugbreak="False"> <action repeatuntil="success" priority="" parametervalues="MzIAWm9tYmxlcwB0cnVlAEZQ" parameters="RmxlZURpc3RhbmNlAEZsZWVGcm9tAFN0YXlPbkdyYXBoAEZsZWVUYXJnZXRWYXJpYWJsZQ==" namespace="" name="Run" debugbreak="False" classname="ChooseFleePosition" /> <move turnspeed="" repeatuntil="" priority="" name="Run" movetarget="FP" movespeed="HSpeed" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> <move turnspeed="" repeatuntil="" priority="" name="Check" movetarget="" movespeed="" facetarget="Enemies" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> <move turnspeed="" repeatuntil="" priority="" name="Clear" movetarget="" movespeed="" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> <parallel tiebreaker="fail" succeed="any" repeatuntil="" priority="" name="parallel" fail="all" debugbreak="False"> <timer waitforsec="Random(4.8)" returnvalue="failure" name="timer" debugbreak="False" /> <detect sensor=""Eyes"" repeatuntil="success" name="detect" matchtype="best" entityobjectvariable="Enemies" debugbreak="False" consistent="True" aspectvariable="" aspectobjectvariable="" aspect=""Enemy"" /> </parallel></sequencer></parallel></selector></parallel></constraint></sequencer></behaviortree>
-
AuthorPosts
You must be logged in to reply to this topic.