-
Search Results
-
Hi,
I am currently creating a game where the enemies swarm the main character but I am having some issues.
I set up my enemies so that they have a behavior tree that only says detect player with the visual sensor and then move to player detected variable. When I set it to move to waypoints it will use the navmesh and properly move towards those but it won’t move towards the player. Is there a different way I can set this up so the enemy is constantly moving towards the player after it is spawned? Any help would be appreciated, thanks!Topic: Trouble with Attack behavior
Hello,
I have a BT set up to patrol and then attack when the player gets close enough. This all works well, but on the attack I have a custom action to send damage. This action gets called a couple times and then no more, even though the attack animation continues to play. It seems to just stay in the attack mode and not keep going through the behavior tree. In addition I added a timer to do the attack for a random amount of time and in parallel I have a pause node that should idle the character for a random amount of time and then it should start attacking again. This is patterned after the patrol and pause example. So I don’t understand why it seems to stay in the attack animation which continuously plays and never pauses, and yet the custom action to send damage only runs a couple times?
<behaviortree version="1.1" repeatuntil="" name="SimplePatrol" debugbreak="False"> <parallel tiebreaker="fail" succeed="all" repeatuntil="" name="root" fail="any" debugbreak="False"> <selector usepriorities="False" repeatuntil="running" name="selector" debugbreak="False"> <constraint repeatuntil="" priority="" name="Player Out of Range" debugbreak="False" constraint="playerDetect == null"> <sequencer usepriorities="False" repeatuntil="" name="Patrol and Pause" debugbreak="False"> <parallel tiebreaker="fail" succeed="all" repeatuntil="" priority="" name="Patrol" fail="any" debugbreak="False"> <waypointpatrol waypointsetvariable=""PatrolRoute"" waypointactiontype="patrol" traversetype="pingpong" traverseorder="forward" repeatuntil="" pathtargetvariable="" name="waypointpatrol" movetargetvariable="moveTarget" debugbreak="False"> <parallel tiebreaker="fail" succeed="any" repeatuntil="" name="Move" fail="any" debugbreak="False"> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="walk" /> <move turnspeed="" repeatuntil="" name="move" movetarget="moveTarget" movespeed="1" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> </parallel> </waypointpatrol> <timer waitforsec="random(2,10)" returnvalue="success" name="patroltimer" debugbreak="False" /> </parallel> <parallel tiebreaker="fail" succeed="all" repeatuntil="" priority="" name="Pause" fail="any" debugbreak="False"> <timer waitforsec="random(1,4)" returnvalue="success" name="pausetimer" debugbreak="False" /> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="idle" /> </parallel> </sequencer> </constraint> <constraint repeatuntil="" priority="" name="Player in Range" debugbreak="False" constraint="playerDetect != null"> <selector usepriorities="False" repeatuntil="" name="selector" debugbreak="False"> <constraint repeatuntil="" priority="" name="tooFarToAttack" debugbreak="False" constraint="nearPlayer == null"> <parallel tiebreaker="fail" succeed="all" repeatuntil="" name="parallel" fail="any" debugbreak="False"> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="run" /> <move turnspeed="" repeatuntil="" name="move" movetarget="playerDetect" movespeed="2" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> </parallel> </constraint> <constraint repeatuntil="" priority="" name="closeUp" debugbreak="False" constraint="nearPlayer != null"> <sequencer usepriorities="False" repeatuntil="" name="sequencer" debugbreak="False"> <parallel tiebreaker="fail" succeed="all" repeatuntil="" priority="" name="hit" fail="any" debugbreak="False"> <move turnspeed="" repeatuntil="" name="move" movetarget="" movespeed="" facetarget="nearPlayer" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="attack" /> <action repeatuntil="" parametervalues="" parameters="" namespace="(global)" name="action" debugbreak="False" classname="SendDamageToPlayer" /> <timer waitforsec="random(1-3)" returnvalue="success" name="timer" debugbreak="False" /> </parallel> <parallel tiebreaker="fail" succeed="all" repeatuntil="" priority="" name="pauseattack" fail="any" debugbreak="False"> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="idle" /> <timer waitforsec="random(1,2)" returnvalue="success" name="timer" debugbreak="False" /> </parallel> </sequencer> </constraint> </selector> </constraint> </selector> <detect sensor=""eyes"" repeatuntil="running" name="far" entityobjectvariable="playerDetect" debugbreak="False" aspectvariable="" aspectobjectvariable="" aspect=""Player"" /> <detect sensor=""close"" repeatuntil="running" name="near" entityobjectvariable="nearPlayer" debugbreak="False" aspectvariable="" aspectobjectvariable="" aspect=""Player"" /> </parallel> </behaviortree>
Unformatted:
<scriptableobject version=”1.1″ type=”RAIN.BehaviorTrees.BTAsset”><fields><field value=”<behaviortree version=”1.1″ repeatuntil=”” name=”SimplePatrol” debugbreak=”False”><parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” name=”root” fail=”any” debugbreak=”False”><selector usepriorities=”False” repeatuntil=”running” name=”selector” debugbreak=”False”><constraint repeatuntil=”” priority=”” name=”Player Out of Range” debugbreak=”False” constraint=”playerDetect == null”><sequencer usepriorities=”False” repeatuntil=”” name=”Patrol and Pause” debugbreak=”False”><parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” priority=”” name=”Patrol” fail=”any” debugbreak=”False”><waypointpatrol waypointsetvariable=””PatrolRoute”” waypointactiontype=”patrol” traversetype=”pingpong” traverseorder=”forward” repeatuntil=”” pathtargetvariable=”” name=”waypointpatrol” movetargetvariable=”moveTarget” debugbreak=”False”><parallel tiebreaker=”fail” succeed=”any” repeatuntil=”” name=”Move” fail=”any” debugbreak=”False”><animate repeatuntil=”” name=”animate” debugbreak=”False” animationstate=”walk” /><move turnspeed=”” repeatuntil=”” name=”move” movetarget=”moveTarget” movespeed=”1″ facetarget=”” debugbreak=”False” closeenoughdistance=”” closeenoughangle=”” /></parallel></waypointpatrol><timer waitforsec=”random(2,10)” returnvalue=”success” name=”patroltimer” debugbreak=”False” /></parallel><parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” priority=”” name=”Pause” fail=”any” debugbreak=”False”><timer waitforsec=”random(1,4)” returnvalue=”success” name=”pausetimer” debugbreak=”False” /><animate repeatuntil=”” name=”animate” debugbreak=”False” animationstate=”idle” /></parallel></sequencer></constraint><constraint repeatuntil=”” priority=”” name=”Player in Range” debugbreak=”False” constraint=”playerDetect != null”><selector usepriorities=”False” repeatuntil=”” name=”selector” debugbreak=”False”><constraint repeatuntil=”” priority=”” name=”tooFarToAttack” debugbreak=”False” constraint=”nearPlayer == null”><parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” name=”parallel” fail=”any” debugbreak=”False”><animate repeatuntil=”” name=”animate” debugbreak=”False” animationstate=”run” /><move turnspeed=”” repeatuntil=”” name=”move” movetarget=”playerDetect” movespeed=”2″ facetarget=”” debugbreak=”False” closeenoughdistance=”” closeenoughangle=”” /></parallel></constraint><constraint repeatuntil=”” priority=”” name=”closeUp” debugbreak=”False” constraint=”nearPlayer != null”><sequencer usepriorities=”False” repeatuntil=”” name=”sequencer” debugbreak=”False”><parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” priority=”” name=”hit” fail=”any” debugbreak=”False”><move turnspeed=”” repeatuntil=”” name=”move” movetarget=”” movespeed=”” facetarget=”nearPlayer” debugbreak=”False” closeenoughdistance=”” closeenoughangle=”” /><animate repeatuntil=”” name=”animate” debugbreak=”False” animationstate=”attack” /><action repeatuntil=”” parametervalues=”” parameters=”” namespace=”(global)” name=”action” debugbreak=”False” classname=”SendDamageToPlayer” /><timer waitforsec=”random(1-3)” returnvalue=”success” name=”timer” debugbreak=”False” /></parallel><parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” priority=”” name=”pauseattack” fail=”any” debugbreak=”False”><animate repeatuntil=”” name=”animate” debugbreak=”False” animationstate=”idle” /><timer waitforsec=”random(1,2)” returnvalue=”success” name=”timer” debugbreak=”False” /></parallel></sequencer></constraint></selector></constraint></selector><detect sensor=””eyes”” repeatuntil=”running” name=”far” entityobjectvariable=”playerDetect” debugbreak=”False” aspectvariable=”” aspectobjectvariable=”” aspect=””Player”” /><detect sensor=””close”” repeatuntil=”running” name=”near” entityobjectvariable=”nearPlayer” debugbreak=”False” aspectvariable=”” aspectobjectvariable=”” aspect=””Player”” /></parallel></behaviortree>” type=”System.String” id=”treeData” /><field type=”System.Array” id=”treeBindings” elementtype=”System.String” /></fields><references /></scriptableobject>
Thanks,
-Dave.
Hi guys, i don’t understand why the ai get stuck when lose the player, what’s the problem?
Thank you for your help.
<behaviortree version="1.1" repeatuntil="" name="SimplePatrol" debugbreak="False"> <parallel tiebreaker="fail" succeed="any" repeatuntil="" name="Patrol and Pause" fail="all" debugbreak="False"> <detect sensor=""eyes"" repeatuntil="running" name="detectHero" entityobjectvariable="detectedHero" debugbreak="False" aspectvariable="" aspectobjectvariable="" aspect=""aHero"" /> <detect sensor=""close"" repeatuntil="running" name="detectIfNear" entityobjectvariable="nearHero" debugbreak="False" aspectvariable="" aspectobjectvariable="" aspect=""aHero"" /> <selector usepriorities="False" repeatuntil="" name="selector" debugbreak="False"> <constraint repeatuntil="" priority="" name="constraint" debugbreak="False" constraint="detectedHero == null"> <waypointpatrol waypointsetvariable=""PatrolRoute"" waypointactiontype="patrol" traversetype="pingpong" traverseorder="forward" repeatuntil="" pathtargetvariable="" name="Patrol" movetargetvariable="moveTarget" debugbreak="False"> <parallel tiebreaker="fail" succeed="any" repeatuntil="" name="Move" fail="any" debugbreak="False"> <move turnspeed="" repeatuntil="" name="move" movetarget="moveTarget" movespeed="2" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="walk" /> </parallel> </waypointpatrol> </constraint> <constraint repeatuntil="" priority="" name="constraint" debugbreak="False" constraint="detectedHero != null"> <selector usepriorities="False" repeatuntil="" name="selector" debugbreak="False"> <constraint repeatuntil="" priority="" name="constraint" debugbreak="False" constraint="nearHero == null"> <parallel tiebreaker="fail" succeed="any" repeatuntil="" name="Move" fail="any" debugbreak="False"> <move turnspeed="" repeatuntil="" name="move" movetarget="detectedHero" movespeed="4" facetarget="" debugbreak="False" closeenoughdistance="" closeenoughangle="" /> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="run" /> </parallel> </constraint> <constraint repeatuntil="" priority="" name="constraint" debugbreak="False" constraint="nearHero != null"> <animate repeatuntil="" name="animate" debugbreak="False" animationstate="punch" /> </constraint> </selector> </constraint> </selector> </parallel> </behaviortree>
Hi Rival Theory!
First of all, thanks for your great library, which I trully find extremely powerfull and well-made.
But I must admit there´s still something to dig around and that is serialization. If I look at your component XML import and export feature, you are throwing away serialized objects and custom data, which leads to reference loss on mount points(sensors, aspects and so on), AIRig body, EntityRig form etc. This can be solved by making custom xml and passing theese objects information and customData to DeserializeInPlace function. That leed mount points to properly load. But only in case of referencing game object in scene. Off-scene objects(prefabs) are not handled properly and all mount points references are loaded the wrong way. The think is, that it shift object references and that leads to assigning bad objects to mount points. In general, RAIN serialization is not capable of holding reference on prefab or asset. Also, AiRig memory is not loaded properly if you don´t clean up the memory first. I made to solve many cases, but I still haven´t managed to correctly serialize components, that have prefab references in them. This problem is most serious with behaviour trees. If you have for example 2 behaviour trees, the object is using one of them, you save the component and after some time, conditions has changed, object is using the 2nd one tree and if you load component to its last state, the first behaviour tree is not loaded(assigned). I am using dynamic composition of objects and I need to be able to construct them according to some scenarious, which specify, how is the object composed and what behaviour trees is using(without editor). If you dont select behaviour tree throw the editor, there is probably no way, how to achieve it.
Finally, my question is, am I right or is there some workaround to achieve saving/loading prefab references correctly.
PS: I am using UnitySerializer, which marks game objects with UniqueIdentifier and I can determine in runtime, whether the object is an instance of prefab or not. Second way could be attach script to object, that assign isPrefab variable to object and set it to true by default. Since off-scene objects dont have their awake function called, you can assign false to isPrefab in this function. That would lead to capability of determing, which gameobject came up from prefab and which not(in runtime).