News Forums Search Search Results for 'tree set variable'

Viewing 15 results - 16 through 30 (of 112 total)
  • Author
    Search Results
  • #34001

    Gamedude
    Participant

    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!

    #33955

    In reply to: 2.0.11 problem…


    jheysonlima
    Participant

    Yep, that’s an old post!!! I’m not working on that project anymore, at least not for now but I remember that I’ve used this method:
    RAIN.Navigation.NavigationManager.Instance.GetNavigationGraph(“YOUR NAVMESH NAME GOES HERE”).IsPointOnGraph(THE POSITION YOU WANT GOES HERE, 0)
    this method returns true if the point is valid and if it is inside the navmesh, you could use it with a raycast to get the world position from the mouse or touch input that you want.
    something like this:

    Ray ray = Camera.main.camera.ScreenPointToRay(Input.mousePosition);
    RaycastHit hit;
    if(Physics.Raycast(ray, out hit, 100))
    {
    if(RAIN.Navigation.NavigationManager.Instance.GetNavigationGraph(“navmesh”).IsPointOnGraph(hit.point, 0)) {
    //THIS BLOCK WILL RUN ONLY IF YOUR MOUSE CURSOR IS OVER A VALID POINT
    //PUT THE ACTION YOU WANT IN HERE
    }
    }

    But I probably haven’t answered your question just yet… where you should use it… well…
    I my case I used it in a script outside rain, and then I created a variable inside rain mind to inform the behaviour tree how it should react. I don’t know if that’s a good practice, maybe other users could help you with that… what I mean is that it will work, but maybe there’s an better way or better place to put it… maybe inside a custom action.

    in my case I did something like this
    AIRig rig = GetComponentInChildren<AIRig>();
    rig.ai.WorkingMemory.SetItem<Vector3>(“lastLocation”, hit.point);

    then my behaviour tree keep checking if this variable “lastLocation” is not null and it takes the accordingly decision such as patrolling or chasing an enemy.

    well hope that my answer will get you started, tell me if my explanation is clear to you… english is not my native language so forgive me for any writing and grammar mistakes

    Hope it helps!

    #33834

    TryHarder
    Participant

    Ok, so by no means finished, but here is the basic theory….. I’m using RFPS but I can’t see it being any different using an UFPS player.

    So to my !!!FPS Player gameobject I added an Entity - RAIN menu crate Entity.
    I then added a visual aspect called aimpoint and set its mount point to my player (I’m going to change this and add an object to the player at head height as the aimpoint)

    I then added an AI RAIN menu - create AI
    I then added a ‘Team’ custom extension (that’s the last little pencil icon in the AI editor) and left as default apart from setting Team to ‘B’
    I then added a ‘Health’ custom extension and set ‘Broadcast Threat Variable’ to playerThreat
    Forgot to say you need to add a communications Manager as well !

    Now drop a DefSoldier in your scene and go pay him a visit and he will shoot at you.

    Now I’m wiring up the health in both directions and changing the behavior tree so the DefSoldier looks for me and does all the usual patrol and attack stuff. Cool thing is if you added some members to your team you have co-op, this is really good fun, and just what I’m looking for you stumble across a lot of NPC battles in my game its part of what its about Robotic enemies being trained to fight us humans back on earth is part of my storyline. If you are interested I have a blog at http://www.thehadroneffect.com

    • This reply was modified 1 month, 3 weeks ago by  TryHarder.
    • This reply was modified 1 month, 3 weeks ago by  TryHarder.
    #33609

    book
    Participant

    Thank you so much again!

    I understand my logic could use a bit of work. But I’ll list out the current states of my alien anyway and let you know what they are doing (or in some cases meant to be doing!).

    I wasn’t really sure how to set it up perfectly with Mecanim so I just have a variable that is set to each animation state and I change that variable in the behaviour tree. It seems to work okay.

    Alien States
    ———————

    PLAYER NOT VISIBLE
    This is activated when the player is NOT in the alien’s EYES sensor.

    HEARD OTHER NOISE
    This state is used for when the Alien hears an item being thrown by the player. He is supposed to walk over to that item and look around. When the player throws an item, when that item hits the ground; if it is in the Alien’s EARS sensor, the alien will switch to SEARCHING OTHER NOISE state. This state is mentioned below.

    The throwable item is a bottle in this scene and it’s called “P3_Throwable_item”.

    HEARD PLAYER NOISE STATE
    This state is used for when the Alien hears the player. I don’t think I ever got it working properly but it’s not a priority feature.

    WANDER STATE
    This is just the alien following the waypoints.

    SEARCHING STATE
    The alien goes to this state after the CHASING STATE (mentioned below) when the player is no longer viewable to the EYES sensor but is still viewable in the “Far Away” sensor. The Far Away sensor does not use line of sight. So the Alien will still move towards the player for a set period of time if the player is still in this sensor. So it isn’t a proper searching state. I didn’t really know how to get the alien to look around the last place the player had been.

    ONALERTSTATE
    The On alert state comes after the searching state. It’s just an animation of the alien looking around before going back to the WANDER state.
    This state is also activated after the SEARCHING OTHER NOISE state when the alien hears a noise and goes to investigate where it happened.

    SEARCHING OTHER NOISE
    This state is activated after the HEARD NOISE state. The alien goes to investigate what noise it heard and will eventually go to the ONALERTSTATE after a given time.

    IDLE STATE
    The alien randomly goes into this state while in the WANDER STATE. This is just to give him a bit more realism.

    PLAYER VISIBLE
    If the player is in the alien’s EYES sensor this state gets activated.

    CHASING STATE
    If the player is only in the EYES sensor but not in the CLOSE sensor. The alien will keep moving towards the player until the player is in the close sensor(in that case alien switches to ATTACKING STATE) or the player escapes the EYES sensor (Note if the player escapes the EYES sensor but is still in the FAR sensor the alien will go to SEARCHING STATE.

    ATTACKING STATE
    If the player is in the alien’s CLOSE sensor the alien swipes at the player. I just put a distance variable in one of the alien scripts (KillPlayer script) that makes the player die if he is too close.

    • This reply was modified 2 months ago by  book.
    • This reply was modified 2 months ago by  book.
    #33603

    prime
    Keymaster

    Thanks for the post!

    A couple of issues to keep in mind:

    - The GameObject associated with a NavigationTarget does not usually represent the position of the target. If you use the variable in this way, you may not get what you want.
    - RAIN’s various movement components (Motor, Move node) recognize Navigation Targets as movement targets, so you can assign the navigation target itself to your variable.
    - You can access a navigation target from the behavior tree in an Expression as navigationtarget(“TargetName”)
    - navigation targets can be accessed by name from the global NavigationManager

    NavigationTarget tTarget = NavigationManager.Instance.GetNavigationTarget("TargetName");
    ai.WorkingMemory.SetItem<NavigationTarget>(NEW_FIRE_POINT, tTarget);
    #33593

    prime
    Keymaster

    Ok - this is all much simpler then. The mistake with your prior code is that it is testing for global left/right - i.e., only along the axis and not relative to the AI itself.

    So:
    1) Turn OFF 3D rotation. If you are doing normal character movement you want that off, otherwise the AI can do some very strange things.
    2) Create a custom action that sets a face target behind the AI:

    Vector3 faceTarget = ai.Kinematic.Position - ai.Kinematic.Forward;
    ai.WorkingMemory.SetItem<Vector3>("faceTarget", faceTarget);

    then add a Move node to your behavior tree that does not have a move target, but has Face Target set to faceTarget.

    This will cause the AI to pick a spot directly behind it (the custom action), set that as a variable in memory (faceTarget), and then turn to face it (move node).

    #33502

    Hoju
    Participant

    Yes, they were warnings not errors. At runtime, I select the parent object and look at the temporary Animator and it shows “None” under Controller.

    It only ever plays the default state. If it is connected to the animator and just not showing it, then the variables it’s calling from the AIRig and Behavior Tree are never going through to the animator for some reason. I’ve checked and rechecked my variables to make sure they are correct but so far I can’t find a mistake anywhere.

    The default state is “Idle” and when bool “Walking” is set to true, it should transition to “Walk” state (as it is set in mecanim). On the AIRig, I created an empty state. Set Mecanim State to “Walk”, Layer 0 (only layer in my animator), set Start Parameter-Parameter Name to “Walking”, Parameter Type to Boolean and Parameter Value to “true”. In Behavior Tree, created a Mecanim-Set Parameter in the part of the tree the it needs to go (this does return Success), and set the value to “Walking = true”.

    Am I missing something here? Should that not transition to the Walk state at this point in runtime?

    #33216

    jiri.navratil
    Participant

    Thanks for the update.
    I know I would save the asset path and I would have done that if the asset object was in the collection SerializedGameObjects of DataSerializer object. But it is not saved with RAIN serialize function, that serializes the component and saves references on objects that are referenced within the component. The only thing I could do is go through all items of components recursively and check, if it is reference with reflection and based on that, save objects on my own. In addition, the deserialization of RAIN counts with right order of the SerializedGameObjects collection. That means, if I can´t insert the asset object at right place, it will shift all asignments and other properties(mount points etc.) would have incorrect references(on different object instead of the one it actually had assigned). Your solution would help only, if the DataSerializer.SerializedGameObjects contains the object or information about the asset, that was referenced. Isn´t there any workaround to achieve this?

    To clarify the deserialization without forcing you to test it on your own, I´ll make an ilustrated example.

    AIRig component - Body reference on GameObject with name “MyRootObject”
    - memory pane - one variable: name - “myobject”, value = “reference on GameObject with name “My1stObject”
    - mind pane - one reference on behaviour tree called “MyTree” ( this is asset!!!)
    - senses pane - 2 audio sensors - 1st one has mount point reference on asset “MySoldier”
    - 2nd one has mount point reference on “My3rdObject”

    Now, when the deserialization occurs, the SerializedGameObjects collection does not contain MyTree and MySoldier. And the following state of component occurs after deserialization:

    Body reference was on scene game object “MyRootObject” - correct
    in memory pane - one variable with reference on scene game object “My1stObject” - correct
    mind pane - had reference on the asset “MyTree” - Lost - now has no reference, because “MySoldier” is not type of BTNode
    - this case is rarity - normally all references are shifted is there is some missing, but Behaviour tree cannot be common asset

    senses pane - 1st audio sensor had mount point reference on asset “MySoldier”, which is lost and now has reference on “My3rdObject”
    - 2nd sensor has no reference (None), because there are on other object references in the collection.

    Other simple example would be :
    AIRig component: Body reference on prefab called “MySoldier” and in memory pane, one variable reference on game object “MyObject”.
    After deserialization, it results in body having “MyObject” reference and variable has no reference.

    Please note, that this last example has almost no use case, assigning body on asset is meaningless. I just wanted to demostrate, what happens. For example with aspects or sensors, it has some meaningful use case.

    I hope that helps clarify what I meant by the deserialization reference shifting due to missing asset references.
    Thank you again. I really appreciate your help.

    • This reply was modified 3 months, 2 weeks ago by  jiri.navratil.
    • This reply was modified 3 months, 2 weeks ago by  jiri.navratil.
    • This reply was modified 3 months, 2 weeks ago by  jiri.navratil. Reason: added some clarification
    #33189

    tapticc
    Participant

    Hi, I have a similar query, I am using a behaviour tree and setting a followPosition variable to the current player’s position so an NPC follows me. I am setting the followPosition variable using an AO.WorkingMemory.SetItem<Vector3> and the character is moving towards the player, but it is not using the NavMesh to bypass non-walkable areas.

    I can understand why this is the case - I have told the NPC to move towards the player, but I am unsure on the best way to move the NPC to a moving target (the player) but stick to the NavMesh.

    Any tips please?

    #33188

    hoodoo
    Participant

    Thank you so much prime. The problem was definitely the animation being looped. Also, I now understand better how to correctly use the parallel and sequencer nodes. Your feedback really helped me! The move I have in there is to make the enemy face the player and I added that because my enemy character started to rotate as it began hitting the player. Not sure if that’s a result of the collision between the two - maybe I should move the enemy back a bit before it starts to attack. Does anyone else have trouble with unwanted rotation during an attack?

    <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="any" 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="any" 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">
                                <sequencer usepriorities="False" repeatuntil="" priority="" name="hit" debugbreak="False">
                                    <move turnspeed="" repeatuntil="" priority="" name="facePlayer" movetarget="" movespeed="" facetarget="nearPlayer" debugbreak="False" closeenoughdistance="" closeenoughangle="" />
                                    <animate repeatuntil="" priority="" name="animate attack" debugbreak="False" animationstate="attack" />
                                    <action repeatuntil="" priority="" parametervalues="" parameters="" namespace="(global)" name="action" debugbreak="False" classname="SendDamageToPlayer" />
                                </sequencer>
                                <parallel tiebreaker="fail" succeed="any" repeatuntil="" priority="" name="pauseattack" fail="any" debugbreak="False">
                                    <animate repeatuntil="" name="animate" debugbreak="False" animationstate="idle" />
                                    <timer waitforsec="random(0,1)" 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>
    #33165

    hoodoo
    Participant

    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.

    • This topic was modified 3 months, 2 weeks ago by  hoodoo.
    • This topic was modified 3 months, 2 weeks ago by  hoodoo.
    • This topic was modified 3 months, 2 weeks ago by  hoodoo.
    • This topic was modified 3 months, 2 weeks ago by  hoodoo.
    • This topic was modified 3 months, 2 weeks ago by  hoodoo.
    #33129

    In reply to: Not finishing a patrol


    markfrancombe
    Participant

    Can we start with this?

    <behaviortree version=”1.1″ repeatuntil=”” name=”Doctor_Heisenhoffer” debugbreak=”False”><parallel tiebreaker=”fail” succeed=”all” repeatuntil=”” name=”root” fail=”any” debugbreak=”False”><waypointpatrol waypointsetvariable=”WaypointRoute1″ waypointactiontype=”patrol” traversetype=”loop” traverseorder=”forward” repeatuntil=”” pathtargetvariable=”” name=”DoctorWanderRoute” movetargetvariable=”nextStop” debugbreak=”False”><move turnspeed=”” repeatuntil=”” name=”move” movetarget=”nextStop” movespeed=”2″ facetarget=”” debugbreak=”False” closeenoughdistance=”” closeenoughangle=”” /></waypointpatrol><mecparam valueexpression=”0″ repeatuntil=”” parametertype=”float” parametername=”Speed” name=”mecparam” debugbreak=”False” damptime=”0″ /></parallel></behaviortree>

    #33076

    cya83
    Participant

    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>
    
    #33051

    jiri.navratil
    Participant

    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).

    #33012

    3dGhost
    Participant

    Looks like your post have already helped me. :)
    After a break I just check this script and looks like it’s working.Weird, because I have test it many times with no luck.

    
    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    using RAIN.Core;
    using RAIN.Action;
    using RAIN.Navigation;
    using RAIN.Navigation.Graph;
    [RAINAction]
    public class WanderLocation : RAINAction
    {
    	public WanderLocation ()
    	{
    		actionName = "WanderLocation";
    	}
        public override void Start(AI ai)
        {
            base.Start(ai);
        }
        public override ActionResult Execute(AI ai)
        {
    		var loc = Vector3.zero; //Default
    		//Create a navigation graph collection.
    		List<RAINNavigationGraph> found = new List<RAINNavigationGraph> ();
    		//Create a vector location based on our AI current location
    		//plus random range values for x and z coordinates
    		do {
    						loc = new Vector3 (ai.Kinematic.Position.x + Random.Range (-15f, 15f),
    			                  ai.Kinematic.Position.y,
    			                  ai.Kinematic.Position.z + Random.Range (-15f, 15f));
    						//We will create navigation points using the above calculated value, the AI current position and ensure that it is within the bounds of our navigation graph
    						found = NavigationManager.Instance.GraphsForPoints(ai.Kinematic.Position
    			                                            					, loc
    			                                             					, ai.Motor.StepUpHeight
    			                                            					, NavigationManager.GraphType.Navmesh
    			                                                				, ((BasicNavigator)ai.Navigator).GraphTags);
    				} while ((Vector3.Distance(ai.Kinematic.Position, loc) <2f) || (found.Count == 0));
    		//We will define a runtime variable in the AIRigs Memory element panel.
    		ai.WorkingMemory.SetItem<Vector3>("varMoveTo", loc);
    		return ActionResult.SUCCESS;
        }
        public override void Stop(AI ai)
        {
            base.Stop(ai);
        }
    }
    

    Now seems I have another 2 problems:
    1) Some of my NPCs get stuck on some Waypoints and start turning around.
    2) They hit in each other sometimes.
    I use the same BehaviorTree from the picture in the first post.
    PS:Sorry for my english.

    • This reply was modified 4 months ago by  3dGhost.
Viewing 15 results - 16 through 30 (of 112 total)