Search Unity

Behavior Designer - Behavior Trees for Everyone

Discussion in 'Assets and Asset Store' started by opsive, Feb 10, 2014.

  1. IL4Mi3y

    IL4Mi3y

    Joined:
    Dec 29, 2014
    Posts:
    38
    @opsive

    Thank you for your support.
    Can you give me an example tree with a parallel task for the fade task?

    Edit: I'll create an account later on.
    I now edited my trigger. (Left side)

    I think this should work better?
    ChestBehaviorScreenshot.png
     
    Last edited: May 19, 2015
  2. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    That is looking better. You can probably remove some of the conditional aborts though. You only need to use the conditional abort when there is a conditional task as the direct child. The aborts on the Sequence and Parallel tasks aren't going to be doing anything. The first screenshot from this tree shows an example of using the parallel task. In addition, take a look at this help topic as it explains how I made a complete behavior tree (which includes parallel tasks)
     
  3. khan-amil

    khan-amil

    Joined:
    Mar 29, 2012
    Posts:
    206
    Hey, just upgraded to 1.5.1, and I'm back with bugs :D

    This one may not be a bug, and maybe just me misunderstanding the feature, but the "referenced behavoir" shows nothing on my trees. I thought it was supposed to get references to external and prefab version of the tree?

    Next I tried to play with the movement pack (+A* project free), did a quick test with flock but it didn't seem to produce any meaningful movement with the 6 agents I passed to it, though I need to test it further, maybe the default parameter were off.
    The follow leader action works great, but I got the following spamming the console when I stop playing in the editor :
    (I had the behavior editor open on the GO with the follow leader task open the whole time, if that helps)


    Now, two little requests :D
    -Variable management can become a little tedious if you use more than a couple. It would be great to have some way to sort/arrange them. I think simply adding a separator/header would be sufficient, and with the up/down sorting already in place we could arrange them as we need.
    -On the same topic, and since variables are locked for instances, that means that designers can't change a value for a specific instance, short of creating a new prefab for each variant. So I made a little script that exposes some variables to the inspector and auto set them at start, but it would be great to have the option to expose some variables to the inspector, much like you can do with playmaker (see here, the "control" drop down lists all the variables I checked to show in the inspector).
     
  4. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    This dropdown will show any tree is being referenced from within the current tree. It will search through the tasks for any public Behavior or ExternalBehavior reference. This means that if you are getting the behavior tree at runtime through a GameObject reference this dropdown will not show that tree.
    Somebody else actually reported that about a week ago. I haven't been able to reproduce it but I did make a change which may help. I'll send you that version to see if it works on your end. In terms of flock, yeah, the parameters are sensitive. With some pathfinding implementations it is easier to get 'good' values but the A* Pathfinding Project is one of the more difficult ones.

    Have you tried clicking outside the variable field to expose more variable properties?
    variables.PNG
    I like the idea. Right now if you have an external tree referenced within the behavior tree component it will allow you to override the external tree's variables, and I think that something like that could work as well for prefabs. I could also try exposing it on the behavior tree component similar to what Playmaker does. I should be able to get this in the next version.
    external.PNG
     
  5. IL4Mi3y

    IL4Mi3y

    Joined:
    Dec 29, 2014
    Posts:
    38
    @opsive
    I have also some ideas for BD.
    1. Is it possible to make something like a quick search?
      So when I press "Space" a little dialog is shown and when I'm beginning to type he filters all tasks.
      When I now press "Enter" the selected task is created. This would make the work with BD faster.
      And even easy to implement because you already have the search procedure. (Inspector on the left)
    2. Is it possible to make a "multi-connect"?
      So when I want to connect multiple tasks with composites I have to do it seperatly.
      It would be great if I can select more than one task and connect all tasks.
    multiconnect.png

    Edit:

    I habe some more ideas, that are nice to have in my opinion. :)
    • Nice when double click on an external behavior tree would open it
    • Deleting a task(s) can't be redo (Strg+Z) Or am I'm doing something wrong?
    • Graphical info which tasks can take more than one child would be great (see image)
      Just an example, I'm glad you have better ideas doing this! :)
      multiple-subtask.png
    • Count info of tasks and external trees in the subline would be awesome. (next to the error number for example)
    • Error info directly next the error icon when clicking it would speed up the work.
    Behavior designer is simply an incredibly good asset! Buy it!
     
    Last edited: May 22, 2015
  6. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    @IL4Mi3y -

    I like it! That quick search idea should really speed things up. I wrote them both down for 1.5.2.
     
  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Looking at your edit -

    It should be able to. By chance do you have the preference "Open referenced tree on task double click" disabled?


    Have you updated to 1.5.1? There was a problem with undo/redo and deleting tasks within a prefab on Unity 5 but that should be fixed now

    Are you talking about having a different bottom connector if it can accept multiple tasks?

    I'm trying to keep things as clean as possible just so the interface doesn't get too cluttered. In what situation do you need to know the number of child tasks? I could see wanting to have the number of external behavior trees referenced from that task, maybe it can appear when you click on the magnifying glass next to field.

    This kind of goes along with the last one and keeping the interface clean. Maybe if you select the task the error info could appear at the bottom toolbar in addition to the part that shows the number of errors. This would prevent you from having to open the error window to see what it is.

    :)
     
  8. IL4Mi3y

    IL4Mi3y

    Joined:
    Dec 29, 2014
    Posts:
    38
    Did not see it. Great!

    Yeah. I mean that it looks only a bit different. (Like a bigger border or something like that)

    I mean the number of all tasks in the tree would be nice. Just a little info at the bottom.
     
  9. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13
    @opsive
    Hi,I want to modify the custom task name which is showed in task list, but I cannot do it.
    ex:
    upload_2015-5-27_11-27-17.png


    "Attack Action" is the custom action class, and I want to show my custom name like "Attack" or other...
    Code (CSharp):
    1. public class AttackAction : Action
    2. {
    3. ....
    4. }
    I don't want to modify the class name, could you give us like ‘[TaskName("Attack")]’ or other method。
    just like:
    Code (CSharp):
    1. [TaskName("Attack")]
    2. public class AttackAction: Action
    3. {
    4. }
    then show in the task list, like
    upload_2015-5-27_11-28-52.png


    thank you.
     

    Attached Files:

    • 1.png
      1.png
      File size:
      17.6 KB
      Views:
      1,001
  10. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    Just wanted to drop by and mention how much I am loving Behavior Designer.

    Right now, it alone is why I use Unity (as opposed to my own engine). It is what makes Unity a great engine (and assets similar in quality to it. These asset store assets are why Unity is a good choice, and without them I'd never refer people to use Unity).

    Anyway, although I can't show a video or anything particularly awesome yet (still too early) I am finally done with my first major behavior tree.

    It's for the game's Animal AI.

    My animals know their threats, their diet, their bedtime, and their collision (what to avoid colliding with, what they cant walk through, etc.) through simple lists I can edit in the Unity Inspector. Behavior Designer takes from a single NPC script, accessing all this information.

    They respond to being attacked, daylight change, threat appearing/chasing them, threat messing around their home, and can search for food, wander for food, and take food and carry it back to their home to reproduce.
    All while using pathfinding based on simple raycasting, physics overlaps, etc. (and Behavior Designer handles all of this, including the pathfinding).

    Learning how to connect all of that, use the difference composites (parallels, sequences, conditionals etc.), and the conditional aborts- it is all wonderful. It took me a bit of experimenting to figure it all out, but after a few days I get it now and it's really easy to make AI.

    It's a pleasure to write my own scripts/actions and add them in. Just awesome. Well documented, easy enough to figure out when confused by experimenting, and overall a smooth learning experience for someone who has never done anything related to AI before.

    Performance is also awesome. Even without going through that much optimization, I can run hundreds of gameobjects all moving around constantly checking collision and AI decisions, and it's super smooth.

    I don't think you can really see my tree, but I just wanted to upload a pic anyway to show its size. Before this, I never did anything bigger than just a few nodes messing around. Now, I actually have AI which responds to everything I need it to :)

    The GUI for Behavior Designer makes it really easy to see / read behavior trees. I never had any trouble knowing what connected to what, what order things were in, or how I should order things. It's a great GUI. Going from Left to Right order just made a lot of sense. The conditional aborts made a lot of sense too. Great stuff.

    animalAI.png


    Thanks Behavior Designer. Without your asset, I would have had to make my own behavior tree GUI and would have spent a lot of time implementing my own behavior tree system. This asset saved me a lot of time and study which I won't have to do for my game! :)

    This time saving is invaluable since my deadline is coming down on me so fast. Well worth the money to anyone who is thinking about the purchase.
     
    Last edited: May 27, 2015
    opsive likes this.
  11. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    @jamesliulyc -

    Sure, I can add that to the next version.

    @CarterG81 -

    That's really great to hear. You structured your tree really well. When you get past the prototyping stage and can post a video of the AI in action I'd love to see it!
     
  12. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13
    @opsive
    wait in hope for your next version.
    sometimes, I just create a template which is like "base_template.asset"(not base_template.prefab) file from the behavior designer.
    then I create a lot of object, and select this template from a list in the my custom inspector, just change the task node parmater.
    like the playmaker(ps: I decide to remove the playmaker plugin from the project).

    upload_2015-5-28_14-24-46.png

    upload_2015-5-28_14-29-20.png

    or
    Click Edit---->open playmaker editor-->right click--->Add FSM Component-->Use Template--->...
    upload_2015-5-28_14-50-41.png

    thanks.
     

    Attached Files:

  13. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
  14. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13
    thanks for your answer.
    But Behavior Tree Reference cannot edit,just only view mode. I just want to .asset file to my windows,and modify the task param in this tree. only one tree for this object has modified, not other objects.
    when open .asset file, then affected all objects which was joined this .asset file.
    thanks.
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    If you click on the External Tree you can then edit that tree. Also, you can override any variables from your local behavior tree to your External Tree. If you have referenced the External Tree from the Behavior Tree component then you can add the variables directly to the non-external tree. If you are using the Behavior Tree Reference task then it will automatically override any external variables from the parent tree if the variables have the same name and type.
     
  16. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13
    @opsive
    I create the custom class,
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using BehaviorDesigner.Runtime;
    4.  
    5. [ExecuteInEditMode]
    6. public class BDTreeMaker : MonoBehaviour {
    7.  
    8.     public BehaviorTree _tree;
    9.  
    10. }
    11.  
    attached this component to one object, like
    upload_2015-5-29_9-53-56.png

    and I create another gui class,
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEditor;
    4. using BehaviorDesigner.Editor;
    5. using BehaviorDesigner.Runtime;
    6.  
    7. [CustomEditor(typeof(BDTreeMaker))]
    8. public class BDTreeMakerInspector :   Editor
    9. {
    10.     private static bool folds = true;
    11.     private int mCount;
    12.     private string[] allName = {"Base Tree 1","Base Tree 2"};
    13.  
    14.     #region onInspectorGUI
    15.     public override void OnInspectorGUI()
    16.     {
    17.        mCount =  EditorGUILayout.Popup("Open BD List", mCount, allName);
    18.        if (GUILayout.Button("Open BD Tree", GUILayout.Height(20)))
    19.        {
    20.            BDTreeMaker maker = target as BDTreeMaker;
    21.            GameObject gameObject = maker.gameObject;
    22.        
    23.            if (gameObject == null) return;
    24.            if (maker._tree == null)
    25.            {
    26.                ExternalBehaviorTree behaviorTree = Resources.Load("BDTemplate/BaseBahavior", typeof(ExternalBehaviorTree)) as ExternalBehaviorTree;
    27.                maker._tree = gameObject.AddComponent<BehaviorTree>();
    28.                maker._tree.SetBehaviorSource(behaviorTree.GetBehaviorSource());
    29.                maker._tree.GetBehaviorSource().behaviorName = behaviorTree.GetBehaviorSource().behaviorName;
    30.                maker._tree.GetBehaviorSource().behaviorDescription = behaviorTree.GetBehaviorSource().behaviorDescription;
    31.            }
    32.            else
    33.            {
    34.                maker._tree = gameObject.GetComponent<BehaviorTree>();
    35.            }
    36.        
    37.            BehaviorDesignerWindow.ShowWindow();
    38.            if (BehaviorDesignerWindow.instance != null)
    39.            {
    40.                Debug.Log("Behavior tree " + maker._tree.name + " Source is " + maker._tree.GetBehaviorSource());
    41.                BehaviorDesignerWindow.instance.LoadBehavior(maker._tree.GetBehaviorSource(), true, true);
    42.            }
    43.        
    44.        }
    45.  
    46.      
    47.     }
    48.     #endregion
    49. }
    50.  
    upload_2015-5-29_9-57-19.png


    and BaseBehavior.asset in the Resources/BDTemplate folder.
    upload_2015-5-29_9-58-50.png

    finally, I clicked "Open BD Tree", show me "BehaviorDesignerWindow.instance" is null.
    thank you
     
    Last edited: May 29, 2015
  17. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13

    and show some error:
    upload_2015-5-29_10-13-28.png
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Here's what the source looks like for the Behavior Tree component's inspector:

    Code (csharp):
    1.  
    2.   if (GUILayout.Button("Open Behavior Designer")) {
    3.     BehaviorDesignerWindow.ShowWindow();
    4.     BehaviorDesignerWindow.instance.LoadBehavior(behavior.GetBehaviorSource(), false, true);
    5.   }
    6.  
    When ShowWindow is called the instance is set so you can then call LoadBehavior. Based on your error it looks like the instance isn't null but something went wrong when LoadBehavior was trying to load your tree. Try setting the second parameter to false:

    Code (csharp):
    1.  
    2. BehaviorDesignerWindow.instance.LoadBehavior(maker._tree.GetBehaviorSource(), false, true);
    3.  
     
  19. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13
    add this code,
    Code (CSharp):
    1. maker._tree.GetBehaviorSource().Owner = maker._tree;
    and
    Code (CSharp):
    1. BehaviorDesignerWindow.instance.LoadBehavior(maker._tree.GetBehaviorSource(), false, true);
    Thank you for your support. It is a great asset.
     
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    @jamesliulyc -

    Ah, that makes sense. Glad you got it figured out!
     
  21. Wenceslao

    Wenceslao

    Joined:
    Feb 7, 2009
    Posts:
    142
    Can anyone recommend a way to upgrade from 1.4.6 to 1.5.1 without losing all my settings in the Variable Synchronizer? It seems I have to delete the Behavior Designer folder in order to update but all my instances and prefabs lose their settings for the variable synchronizer because the script goes missing. Of course when I reconnect it the settings are lost.

    I suppose one way would to use another solution for pushing data back and forth between the behavior tree and the gameobject.
     
  22. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Unity makes these associations from the data within the meta files. You should be able to completely delete Behavior Designer and import it again without losing anything. Is it just the Variable Synchronizer? If the association is lost for some reason you should be able to drag the VariableSynchronizer component reference over to the missing script field and all you data will remain in tact.
     
  23. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13
    @opsive
    Hi,I meet a big problem, I cannot copy(or insert) my template to the behavior tree.
    Could you provide the coping/insert template feature.:(
    Of course, I can can either be added directly to the Behavior Tree Component or referenced using the Behavior Tree Reference task.
    But I just want to copy(insert) the behavior tree reference task to my behavior tree, then I can edit the param for the task which is copyed from the reference tree. I have no permission to modify the param of the reference task.
    Yes, you maybe suggest copping the reference file, and rename to another file name.
    But, it isn't very easy. I have 80 behavior trees, they probably need to the same reference tree, but their param is different.then I maybe copy 80 the same reference tree, and rename them.:(
     
  24. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I'm not completely following - when you say template, you mean External Tree, right? Also, you can copy the Behavior Tree Reference task and it will copy the fields along with it. You can then change those values if you want to.
     
  25. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13

    Yes, it is External tree, but I cannot use like "insert external tree" to my editor area.

    When I open the Bebehavior Editor, right click like "insert reference tree" item, then this tree would copy to my editor area, and show it into the current entry which was editting.
     
  26. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    On the Behavior Tree component you can insert your external tree there, or you can copy a Behavior Tree Reference task from another tree and the External Tree reference will persist. Do either of those options work?
     
  27. jamesliulyc

    jamesliulyc

    Joined:
    May 27, 2015
    Posts:
    13
    Sure, that is no problem. But, it is inconvenience. if it have the "insert the reference tree to another tree", maybe it is perfect.
    Thank you for your help.
     
  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    What sort of workflow would make it easier? I guess I'm not following exactly what you are trying to do.
     
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Behavior Designer 1.5.2 has been released on the Asset Store and sent to opsive.com purchases. You can see the full change list here.

    The highlight of this release includes support for Unity 5 networking. SharedVariables will automatically synchronize from the server to the clients:

    VariableNetworkSync.png

    See this documentation topic for more information.
     
    hopeful likes this.
  30. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    The Behavior Designer - Tactical Pack has been released on the Asset Store!

    Screenshot1.png

    Screenshot2.png

    The Behavior Designer - Tactical Pack contains 14 different behaviour tree tasks focused on tactical situations with Unity's NavMesh.

    Attacking is unique to each game. The Tactical Pack uses interfaces so you can implement your own attack and damage logic that fits your game.

    You can see a demo of the Tactical Pack on this page and follow the Tactical Pack progress within this thread.
     
  31. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I assume that these all work fine with Realistic FPS, right?
    I mean Behavior Designer and the add ons.
     
  32. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    OK I grabbed it.
    Imported into my rather dodgy test project/scene (too many things have been imported here and played with). I get this error.

    Assets/Behavior Designer/Runtime/Variables/SharedBool.cs(9,81): error CS0103: The name `ValueChanged' does not exist in the current context..

    Anyway, time to set up a clean project. So I have RFPS and BH. I went to the opsiv.com site to grab the integration files, but can't see them. I just get stuck in an endless redirection. One page saying it is on the the other, which says it has been moved to the first, which says it is on the other.. ... ...

    Where can I grab these from please?
    ---------------------

    Update.. Never mind.. Worked it out.. Must learn to read instructions.. Even simple ones. ;-)
     
    Last edited: Jun 18, 2015
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Behavior Designer supports RPFS (just updated it to use version 1.22, make sure you get the integration and sample again). You can use the Movement and Formations Pack with a RFPS agent, but since the Tactical Pack is so new it doesn't have any integrations yet. RFPS would be a good integration to add to that pack.

    Glad you got it figured out :) I just updated that RFPS documentation link to point to the samples page instead of the integrations page. In the past the samples and integrations were on different pages but I combined them to make it easier to get both the sample and integration files.
     
  34. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Just running through the integration on a clean install of the latest RFPS and latest BH.
    Integration steps have been followed.
    1/ Here is the first error. Just seems like firstWayPoint is meant to be firstWaypoint. Changing it fixes this error.
    Assets/Behavior Designer/Third Party/Realistic FPS Prefab/Tasks/Patrol.cs(27,47): error CS1061: Type `BehaviorDesigner.Runtime.Tasks.RFPS.AIAgent' does not contain a definition for `firstWayPoint' and no extension method `firstWayPoint' of type `BehaviorDesigner.Runtime.Tasks.RFPS.AIAgent' could be found (are you missing a using directive or an assembly reference?)

    2/ After the above change I then get this error:
    Assets/Behavior Designer/Third Party/Realistic FPS Prefab/Tasks/Patrol.cs(27,25): error CS0029: Cannot implicitly convert type `int' to `UnityEngine.Transform'

    Suggestions?
     
  35. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Have you downloaded the latest RFPS tasks? Based on those errors it looks like you are using the previous version of the tasks.
     
  36. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I downloaded everything yesterday.
    This package right? RealisticFPSAssets.unitypackage which is 23,913 bytes
     
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    It looks like you are using the previous version - I updated the package this morning after checking the RFPS integration. After you download the new integration and sample package take a look at the RFPS documentation page again. There are only three changes to make so once you do that you should be good to go.
     
  38. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    OK. I will go through a clean one again now to be sure and let you know.
     
  39. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I have now redone the clean install and those errors are gone.
    Just a question then... When you have completed the integration and BH now has control in the sandbox demo, should there now be a bunch of other errors? Like these:

    MissingComponentException: There is no 'Animation' attached to the "SoldierBadNPC" game object, but a script is trying to access it.
    You probably need to add a Animation to the game object "SoldierBadNPC". Or your script needs to check if the component is attached before using it.
    AI.OnEnable () (at Assets/RFPSP/Scripts/AI/AI.cs:175)

    UnassignedReferenceException: The variable playerObj of AIAgent has not been assigned.
    You probably need to assign the playerObj variable of the AIAgent script in the inspector.
    UnityEngine.GameObject.GetComponent[FPSPlayer] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineGameObjectBindings.gen.cs:35)
    NPCAttack.OnEnable () (at Assets/RFPSP/Scripts/AI/NPCAttack.cs:53)

    NullReferenceException: Object reference not set to an instance of an object
    CharacterDamage.Die () (at Assets/RFPSP/Scripts/AI/CharacterDamage.cs:83)
    UnityEngine.Component:SendMessage(String)
    CharacterDamage:ApplyDamage(Single, Vector3, Vector3, Transform, Boolean) (at Assets/RFPSP/Scripts/AI/CharacterDamage.cs:71)
    WeaponBehavior:HitObject(RaycastHit, Vector3) (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:1116)
    <FireOneShot>c__Iterator1A:MoveNext() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:1071)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    WeaponBehavior:Fire() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:987)
    WeaponBehavior:Update() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:792)
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Great to hear that it compiles without a problem.

    You definitely shouldn't be getting any errors with the sample. I just downloaded a fresh copy off the sample off of the samples page and it didn't throw any errors. Does the RFPS FPS Prefab Sandbox scene work for you?
     
  41. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I was not using the sample. I was using the RFPS prefab sandbox. So those errors were to do with the sandbox scene.

    I have imported the sample now, but get these errors:

    NullReferenceException: Object reference not set to an instance of an object
    CharacterDamage.Die () (at Assets/RFPSP/Scripts/AI/CharacterDamage.cs:83)
    UnityEngine.Component:SendMessage(String)
    CharacterDamage:ApplyDamage(Single, Vector3, Vector3, Transform, Boolean) (at Assets/RFPSP/Scripts/AI/CharacterDamage.cs:71)
    WeaponBehavior:HitObject(RaycastHit, Vector3) (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:1116)
    <FireOneShot>c__Iterator1A:MoveNext() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:1071)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    WeaponBehavior:Fire() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:987)
    WeaponBehavior:Update() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:792)

    Damaged
    UnityEngine.Debug:Log(Object)
    BehaviorDesigner.Runtime.Tasks.Log:OnUpdate() (at Assets/Behavior Designer/Runtime/Actions/Log.cs:21)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunParentTask(BehaviorTree, Int32, Int32&, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunParentTask(BehaviorTree, Int32, Int32&, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:Tick(BehaviorTree)
    BehaviorDesigner.Runtime.BehaviorManager:Tick()
    BehaviorDesigner.Runtime.BehaviorManager:Update()

    NullReferenceException: Object reference not set to an instance of an object
    AI+<Patrol>c__Iterator5.MoveNext () (at Assets/RFPSP/Scripts/AI/AI.cs:370)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    BehaviorDesigner.Runtime.Tasks.RFPS.Patrol:OnStart() (at Assets/Behavior Designer/Third Party/Realistic FPS Prefab/Tasks/Patrol.cs:29)
    BehaviorDesigner.Runtime.BehaviorManager:pushTask(BehaviorTree, Int32, Int32)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunParentTask(BehaviorTree, Int32, Int32&, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:Tick(BehaviorTree)
    BehaviorDesigner.Runtime.BehaviorManager:Tick()
    BehaviorDesigner.Runtime.BehaviorManager:Update()
     
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    So you tried the FPS Prefab Sandbox scene and it gave this set of errors, and then you tried the Behavior Designer scene and it gave this set? Did I get that right? If the regular RFPS sandbox scene doesn't work then the Behavior Designer sample scene isn't going to work. Which version of Unity are you running? RFPS requires 5.0.1 or higher.
     
  43. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I should note that the sandbox scene works as expected before adding BH and integrating.

    Unity is 5.1.0f3
    RFPS is 1.22
    BD is 1.5.2a

    I don't mind running through it all again, step by step if it helps pinpoint where it is going awry.
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Here's what I did to get it to work:

    - Create a new project in Unity 5.1
    - Import Behavior Designer
    - Import RFPS
    - Download a new set of RFPS integration and sample files from the samples page.
    - Import the integration files
    - Made the three script changes described on this page.
    - Imported the RFPS sample project
    - Opened the RFPS sample project and hit play.

    With these steps the scene ran without any errors and the SoldierBadNPC enemy started to attack me which is controlled by a behavior tree.
     
  45. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I will place steps here and update as I do them. Maybe you can see something.
    New blank project created.
    Imported RFPS package and ran the sandbox scene. It is working fine at this point.
    Next will implement script changes for integration. Back when done and will edit this post.

    Hmmm. I did have more details here but one missed key and they went. So, the short version is... it all works fine until you try to shoot at the enemy. Then you get this in the sample scene.:

    NullReferenceException: Object reference not set to an instance of an object
    CharacterDamage.Die () (at Assets/RFPSP/Scripts/AI/CharacterDamage.cs:83)
    UnityEngine.Component:SendMessage(String)
    CharacterDamage:ApplyDamage(Single, Vector3, Vector3, Transform, Boolean) (at Assets/RFPSP/Scripts/AI/CharacterDamage.cs:71)
    WeaponBehavior:HitObject(RaycastHit, Vector3) (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:1116)
    <FireOneShot>c__Iterator1A:MoveNext() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:1071)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    WeaponBehavior:Fire() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:987)
    WeaponBehavior:Update() (at Assets/RFPSP/Scripts/Weapons/WeaponBehavior.cs:792)


    Damaged
    UnityEngine.Debug:Log(Object)
    BehaviorDesigner.Runtime.Tasks.Log:OnUpdate() (at Assets/Behavior Designer/Runtime/Actions/Log.cs:21)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunParentTask(BehaviorTree, Int32, Int32&, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunParentTask(BehaviorTree, Int32, Int32&, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:Tick(BehaviorTree)
    BehaviorDesigner.Runtime.BehaviorManager:Tick()
    BehaviorDesigner.Runtime.BehaviorManager:Update()


    Also:
    If you die and the game resets the level, this error is shown:

    NullReferenceException: Object reference not set to an instance of an object
    AI+<Patrol>c__Iterator5.MoveNext () (at Assets/RFPSP/Scripts/AI/AI.cs:370)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    BehaviorDesigner.Runtime.Tasks.RFPS.Patrol:OnStart() (at Assets/Behavior Designer/Third Party/Realistic FPS Prefab/Tasks/Patrol.cs:29)
    BehaviorDesigner.Runtime.BehaviorManager:pushTask(BehaviorTree, Int32, Int32)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunParentTask(BehaviorTree, Int32, Int32&, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:Tick(BehaviorTree)
    BehaviorDesigner.Runtime.BehaviorManager:Tick()
    BehaviorDesigner.Runtime.BehaviorManager:Update()


    Another update:
    If I change the Listen Range to 10 from 50. The soldier does not come and attack immediately, which is as expected, but I get this error which does not happen if the soldier hears you and comes to attack:
    NullReferenceException: Object reference not set to an instance of an object
    AI+<Patrol>c__Iterator5.MoveNext () (at Assets/RFPSP/Scripts/AI/AI.cs:370)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    BehaviorDesigner.Runtime.Tasks.RFPS.Patrol:OnStart() (at Assets/Behavior Designer/Third Party/Realistic FPS Prefab/Tasks/Patrol.cs:29)
    BehaviorDesigner.Runtime.BehaviorManager:pushTask(BehaviorTree, Int32, Int32)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunParentTask(BehaviorTree, Int32, Int32&, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:RunTask(BehaviorTree, Int32, Int32, TaskStatus)
    BehaviorDesigner.Runtime.BehaviorManager:Tick(BehaviorTree)
    BehaviorDesigner.Runtime.BehaviorManager:Tick()
    BehaviorDesigner.Runtime.BehaviorManager:Update()
     
    Last edited: Jun 19, 2015
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thanks, that triggered it.

    Open Behavior Designer/Third Party/Realistic FPS Prefab/AIAgent.cs and change:

    Code (csharp):
    1.  
    2.   public override void Start()
    3.   {
    4.     StopAllCoroutines();
    5.   }
    6.  
    to
    Code (csharp):
    1.  
    2.   public override void Start()
    3.   {
    4.     base.Start();
    5.  
    6.     StopAllCoroutines();
    7.   }
    8.  
    And within RFPSP/Scripts/AI/AI.cs change:

    Code (csharp):
    1.  
    2. void Start(){
    3.  
    to
    Code (csharp):
    1.  
    2. public virtual void Start(){
    3.  
    I have also updated the integration files with this first change and updated the documentation with the second change. You do not need to update the scene again. From here you should be good to go!
     
  47. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Those errors are gone now. I'll have a play with it all now.

    Thanks.
     
  48. CaptainMurphy

    CaptainMurphy

    Joined:
    Jul 15, 2014
    Posts:
    746
    We are running into an error trying to build a project in 5.1.1p1 Pro with the latest Behavior Designer asset. Looks like the latest patch broke something.

    Code (csharp):
    1. UNetWeaver error: Rpc function [BehaviorDesigner.Runtime.Behavior:RpcDirtyVariableTransform] parameter [value] is of the type [Transform] which is a Component. You cannot pass a Compent to a Rpc call. Try passing data from within the component.
    2. UnityEngine.Debug:LogError(Object)
    3. Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:19)
    4. Unity.UNetWeaver.NetworkBehaviourProcessor:processMethods() (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetBehaviourProcessor.cs:1343)
    5. Unity.UNetWeaver.NetworkBehaviourProcessor:process() (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetBehaviourProcessor.cs:51)
    6. Unity.UNetWeaver.Weaver:processNetworkBehaviourType(TypeDefinition) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:997)
    7. Unity.UNetWeaver.Weaver:CheckNetworkBehaviour(TypeDefinition) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1436)
    8. Unity.UNetWeaver.Weaver:Weave(String, IEnumerable`1, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1536)
    9. Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1605)
    10. Unity.UNetWeaver.Program:process(String, String, String, String[], String[], Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:33)
    11. UnityEditor.HostView:OnGUI()
     
  49. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    It looks like you are trying to sync a Transform over the network? Based on that callstack and if it was previously working I would report a bug to Unity. Transforms should be able to be used as RPC parameters.
     
    Last edited: Jun 24, 2015
  50. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Hi @opsive ,

    Just starting to play with the BD and RFPS and so just added the Cover as a task from the Movement pack to the tree included in the sample scene. It is probably just my wrong thinking/ lack of reading & testing but, should this not work.
    The Cover task goes green when I shoot the NPC but nothing seems to happen.
    The Cover layer contains just 1 large cube. I re-baked the nav mesh after adding it.

    upload_2015-6-24_10-12-6.png
     
    Last edited: Jun 24, 2015