Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Behavior Designer - Behavior Trees for Everyone

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

  1. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Behavior Designer 1.5.6 was sent to opsive.com purchases a few days ago and is now on the Asset Store. You can see the full release notes within this post. This release contains some major deserialization optimizations and Unity 5.4 support.

    The UnknownTask will also retain the previous task data so it makes task renames/namespace changes much easier to handle. When you see a UnknownTask because of a name change you can now right click and replace it with the new task. All of the previous values will be retained. This was suggested by @21312313123321 within this post and in version 1.6 I plan on extending this to make it easier to handle many trees.
     
  2. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Justin,

    I just installed 1.5.6 and unfortunately the issue with the Inspector being cutoff on the right hand side due to the vertical scroll bar still exists.

    This occurs both when the Behavior Designer Editor window is docked as well as undocked.

    I'm running Unity 5.3.4 on Mac OSX. (I'm wondering if this is a Unity Mac issue.)

    Here are some screenshots before vertical limitations and after vertical limitations. Note in addition to loss of the Shared Variables, I also lose the little gear icon in the upper right. Basically the vertical scroll bar appears to overlay on top of everything.

    Screen Shot 2016-03-17 at 2.42.13 PM.png

    Screen Shot 2016-03-17 at 2.37.36 PM.png

    Allan
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Can you send me a task which adds the horizontal scroll bar? I just tried it again with another task and I didn't see the scroll bar.
     
  4. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Done. Sent by way of conversations.
     
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Thanks for the file - unfortunately it didn't add a scroll bar with this task either. I tried on both Windows and Mac as well as various Unity versions (4.6, 5.2, and 5.3). This may be a stupid question, but are you sure you're on 1.5.6? You can see the version number within the Welcome Screen.

    Besides that, does add a horizontal scroll bar no matter the contents of the task? For example, a lot of SharedFloats?
     

    Attached Files:

    • task.PNG
      task.PNG
      File size:
      31.6 KB
      Views:
      784
  6. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Man this is weird.

    I'm on version 1.5.6.

    I noticed my inspector has a Type field right below name but yours does not. The Type field extends across the Inspector. Is that what is causing the Horizontal scroll bar?
     

    Attached Files:

  7. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I missed that! You're right on the type - the task was renamed so it was displaying the original type and that's what was causing the extra length. Alright, I'll send you a PM with the fixed version :)
     

    Attached Files:

    • task.PNG
      task.PNG
      File size:
      38.5 KB
      Views:
      807
  8. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Actually all of my tasks have a horizontal scroll bar.

    Here is the Can See Enemy task.
     

    Attached Files:

  9. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Hey that fixed it!!

    Nice job.

    Thanks :)
    Allan
     
    Last edited: Mar 17, 2016
    opsive likes this.
  10. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,763
    How would I go about setting up a behaviour tree where I have a variable that, when true, activates the rest of the behaviour tree? Right now I have this tree:



    On success, it's supposed to send an incredibly rude message which I can't repost on the Unity forums to the debug log. This is the code I have for it:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using BehaviorDesigner.Runtime.Tasks;
    4. using BehaviorDesigner.Runtime;
    5.  
    6. public class IsEnemyTurn : Conditional {
    7.  
    8.     public SharedBool isTurn = false;
    9.  
    10.     public override TaskStatus OnUpdate(){
    11.  
    12.         if (isTurn.ToString() == "true") {
    13.             return TaskStatus.Success;
    14.         }
    15.  
    16.         return TaskStatus.Failure;
    17.  
    18.     }
    19. }
    20.  
    I have the variable set to match the variable from the variable menu but when I change it there, the tree doesn't update. I know I'm doing probably everything wrong here but this is my first time using a behaviour tree setup instead of an FSM.
     
  11. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    i think you might change it to something like :

    if(isTurn.Value== true)
     
    opsive likes this.
  12. THoeppner

    THoeppner

    Joined:
    Oct 10, 2012
    Posts:
    205
    You can return TaskStatus.Running as long as isTurn is false. Than the task gets executed each update.

    Code (CSharp):
    1.        
    2. public override TaskStatus OnUpdate()
    3. {
    4.   if (target.Value == true)
    5.   {
    6.     return TaskStatus.Success;
    7.    }
    8.    return TaskStatus.Running;
    9. }
    10.  
     
    opsive likes this.
  13. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,763
    This did the trick, thanks!
    This is a much cleaner method than I was using, thanks to you too!
     
  14. StephenMorris

    StephenMorris

    Joined:
    Mar 25, 2013
    Posts:
    35
    Hi there,

    I'm trying to use your flocking behaviour but I can't seem to find any method to set the destination of the flock. I can see there is a 'Set Destination' which seems to only apply to a single NavMesh agent but overall as a group, it only seems to randomly select a destination.

    Help!

    Many thanks,
    Stephen
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    The flock task does not take a destination - it's more similar to the steering behavior boid flock rather than a Geometry Wars flock. Take a look at this post for how you would get more of a Geometry Wars style flock.
     
  16. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Justin,

    I'm running into a type conflict when trying to create a DoTween Sequence in my tasks. I have the DoTween Integration but I'm guessing it does not include Dotween Sequences unless perhaps I'm doing something wrong with my Using statements. I'm using DG.Tweeing and that provides access to all of the DoTweens I have tried...except for sequences.

    Code (CSharp):
    1. Sequence mySequence = DOTween.Sequence();
    Monodevelop is telling me the type conflict is between:
    BehaviorDesigner.Runtime.Tasks.Sequence,
    DG.Tweeing.Sequence

    If there is something I can do, or if I'm doing something wrong just let me know.
    I'm running the current versions of everything in addition to the patch you provided me that fixed the horizontal/vertical scroll bar issue in the Editor Inspector pane.

    Thanks
    Allan
     
  17. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    What is the full error that you are receiving? Since both DOTween and Behavior Designer have the class Sequence defined you'll need to make sure you use the full namespace for DOTween.
     
  18. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Justin,

    Thanks. That was all the tip I needed. I'm feeling a little dumb. Sometimes I forget the namespace rules with overlapping Assets.

    I needed to use:
    DG.Tweening.Sequence mySequence = DoTween.Sequence();

    Thanks
    Allan
     
    hopeful and opsive like this.
  19. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Justin,

    There is a prior post from about a year ago about using LateUpdate in Behavior Designer Tasks where you describe the use of a component that you enable and disable and you provide a code example.

    Most of the implementation of FinalIK is done in LateUpdate especially things that need ongoing updating like AimIK or LookAtIK.

    I don't entirely understand what you are describing, even with the provided code, about enabling and disabling a component.

    I'm wondering if you have given any additional thought to including a override TaskStatus.LateUpdate so Lateupdate could be implemented directly within tasks.

    Thanks
    Allan
     
  20. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    The Task class does have a LateUpdate override so you can perform your logic in that. It is similar to OnUpdate except it doesn't return a status:
    Code (csharp):
    1.  
    2. public override OnLateUpdate()
    3. {
    4.  
    5. }
    6.  
     
  21. chaneya

    chaneya

    Joined:
    Jan 12, 2010
    Posts:
    416
    Beautiful!

    This worked:
    Code (CSharp):
    1. public override void OnLateUpdate()
    2.     {
    3.         base.OnLateUpdate();
    4.         aimIK.solver.IKPosition = navTargetPos;
    5.     }
    Thanks again.
    Allan
     
  22. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    I'm currently trying to set up a behaviour tree as follows. I'm fairly inexperienced som I'm probably doing some things that are slightly weird ^_^

    upload_2016-4-5_10-40-52.png

    The Pursue however is giving me a bug.
    It used to work just fine, but then at some point it stopped working, when ever I attemt to drag a gameobject over to the target field I get the error that it can't convert Gameobjet to Transform, which is silly as it doesn't need transform..!?

    ArgumentException: Object type UnityEngine.GameObject cannot be converted to target type: UnityEngine.Transform
    Parameter name: val
    System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoField.cs:133)
    System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/FieldInfo.cs:150)
    BinaryDeserialization.LoadFields (BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.Dictionary`2 fieldIndexMap, System.Object obj, Int32 hashPrefix, IVariableSource variableSource)
    BinaryDeserialization.LoadTask (BehaviorDesigner.Runtime.TaskSerializationData taskSerializationData, BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.List`1& taskList, BehaviorDesigner.Runtime.BehaviorSource& behaviorSource)
    BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource)
    BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource)
    BehaviorDesigner.Editor.GraphDesigner.Load (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, Boolean loadPrevBehavior, Vector2 nodePosition)
    BehaviorDesigner.Editor.BehaviorDesignerWindow.LoadBehavior (BehaviorDesigner.Runtime.BehaviorSource behaviorSource, Boolean loadPrevBehavior, Boolean inspectorLoad)
    BehaviorDesigner.Editor.BehaviorDesignerWindow.UpdateTree (Boolean firstLoad)
    BehaviorDesigner.Editor.BehaviorDesignerWindow.OnSelectionChange ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:187)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:180)
    UnityEditor.HostView.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:135)

    Can anyone spot what I'm doing wrong or what has gone wrong?
     
  23. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    Oh, apparently it was the deactivated "Get Field Value" that was causing trouble .. I deactivated it because I thought it might be doing it, but I still had problems after deactivated, I just removed it as part of a cleanup (as I wasn't using it) and everything works now.
     
  24. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    Nope, it goes way deeper. I exchanged parallel for a Sequence reordered the pursue and the overlap check, and I'm now again getting the exact same error.

    upload_2016-4-5_11-49-51.png
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Are you using the latest version, 1.5.6? Also, can you tell me how to reproduce that exception? What does your Overlap Sphere Check task look like?
     
  26. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    I am indeed using 1.5.6

    Cover From is a lightly edited version of the cover task.
    Rather than run to the other side of a wall I want the agent to hide from the specific enemy that is shooting at him.
    You are welcome to the code in or ideas behind these actions, no credits needed etc. if there are better ways to do it, I'm all ears. =)

    Code (CSharp):
    1. using System.Linq;
    2. using System.Security.Cryptography.X509Certificates;
    3. using UnityEngine;
    4.  
    5. namespace BehaviorDesigner.Runtime.Tasks.Movement
    6. {
    7.     [TaskDescription("Find a place to hide and move to it using the Unity NavMesh.")]
    8.     [TaskCategory("Movement")]
    9.     [HelpURL("http://www.opsive.com/assets/BehaviorDesigner/Movement/documentation.php?id=8")]
    10.     [TaskIcon("Assets/Behavior Designer Movement/Editor/Icons/{SkinColor}CoverIcon.png")]
    11.     public class CoverFrom : NavMeshMovement
    12.     {
    13.         [Tooltip("The distance to search for cover")]
    14.         public SharedFloat maxCoverDistance = 1000;
    15.         [Tooltip("The layermask of the available cover positions")]
    16.         public LayerMask availableLayerCovers;
    17.         [Tooltip("The maximum number of raycasts that should be fired before the agent gives up looking for an agent to find cover behind")]
    18.         public SharedInt maxRaycasts = 100;
    19.         [Tooltip("How large the step should be between raycasts")]
    20.         public SharedFloat rayStep = 1;
    21.         [Tooltip("Once a cover point has been found, multiply this offset by the normal to prevent the agent from hugging the wall")]
    22.         public SharedFloat coverOffset = 2;
    23.         [Tooltip("Should the agent look at the cover point after it has arrived?")]
    24.         public SharedBool lookAtCoverPoint = false;
    25.         [Tooltip("The agent is done rotating to the cover point when the square magnitude is less than this value")]
    26.         public SharedFloat rotationEpsilon = 0.5f;
    27.         [Tooltip("Max rotation delta if lookAtCoverPoint")]
    28.         public SharedFloat maxLookAtRotationDelta;
    29.         [Tooltip("Max rotation delta if lookAtCoverPoint")]
    30.         public SharedGameObject coverFromGo;
    31.  
    32.         private Vector3 coverPoint;
    33.         private GameObject targetPosGo;
    34.         private Vector3 target;
    35.  
    36.         public override void OnStart()
    37.         {
    38.             base.OnStart();
    39.  
    40.             target = Target();
    41.             Debug.Log("Target : " + target);
    42.             if(target != Vector3.zero)
    43.                 SetDestination(target);
    44.         }
    45.  
    46.         // Seek to the cover point. Return success as soon as the location is reached or the agent is looking at the cover point
    47.         public override TaskStatus OnUpdate()
    48.         {
    49.             if(target == Vector3.zero)
    50.                 return TaskStatus.Failure;
    51.  
    52.             if (HasArrived())
    53.             {
    54.                 var rotation = Quaternion.LookRotation(coverPoint - transform.position);
    55.                 // Return success if the agent isn't going to look at hte cover point or it has completely rotated to look at the cover point
    56.                 if (!lookAtCoverPoint.Value || Quaternion.Angle(transform.rotation, rotation) < rotationEpsilon.Value)
    57.                 {
    58.                     return TaskStatus.Success;
    59.                 }
    60.                 else {
    61.                     // Still needs to rotate towards the target
    62.                     transform.rotation = Quaternion.RotateTowards(transform.rotation, rotation, maxLookAtRotationDelta.Value);
    63.                 }
    64.             }
    65.  
    66.             // Return running until the agent has arrived
    67.             return TaskStatus.Running;
    68.         }
    69.  
    70.  
    71.         private Vector3 Target()
    72.         {
    73.             var results = Physics.OverlapSphere(transform.position + transform.forward * maxCoverDistance.Value * 0.5f, maxCoverDistance.Value, availableLayerCovers);
    74.  
    75.             if (results.Length == 0)
    76.             {
    77.                 return Vector3.zero;
    78.             }
    79.             else
    80.             {
    81. //                Item biggest = items.Aggregate((i1, i2) => i1.ID > i2.ID ? i1 : i2);
    82.                 var target = results.Aggregate((x, y) => Vector3.Distance(x.transform.position, transform.position) < Vector3.Distance(y.transform.position, transform.position) ? x : y);
    83.  
    84.                 Debug.Log("selected targets possition : " + target.transform.position);
    85.  
    86.                 var coverDirection = (coverFromGo.Value.transform.position - target.transform.position).normalized;
    87.                 return target.transform.position - coverDirection * coverOffset.Value;
    88.             }
    89.         }
    90.  
    91.         // Find a place to hide by firing a ray
    92.         private Vector3 TargetOld()
    93.         {
    94.             RaycastHit hit;
    95.             int raycastCount = 0;
    96.             var direction = transform.forward;
    97.             float step = 0;
    98.             // Keep firing a ray until too many rays have been fired
    99.             while (raycastCount < maxRaycasts.Value)
    100.             {
    101.                 var ray = new Ray(transform.position, direction);
    102.                 if (Physics.Raycast(ray, out hit, maxCoverDistance.Value, availableLayerCovers))
    103.                 {
    104.                     Debug.Log("Running the thingy");
    105.                     if(targetPosGo == null)
    106.                         targetPosGo = GameObject.CreatePrimitive(PrimitiveType.Sphere);
    107.                     var coverDirection = (coverFromGo.Value.transform.position - hit.transform.position).normalized;
    108.  
    109.                     coverPoint = hit.transform.position;
    110.  
    111.                     targetPosGo.transform.position = coverPoint - coverDirection*coverOffset.Value;
    112.                     return coverPoint - coverDirection*coverOffset.Value;
    113.                 }
    114.                 // Keep sweeiping along the y axis
    115.                 step += rayStep.Value;
    116.                 direction = Quaternion.Euler(0, transform.eulerAngles.y + step, 0) * Vector3.forward;
    117.                 raycastCount++;
    118.             }
    119.             // The agent wasn't found - return zero
    120.             return Vector3.zero;
    121.         }
    122.  
    123.         // Reset the public variables
    124.         public override void OnReset()
    125.         {
    126.             base.OnStart();
    127.  
    128.             maxCoverDistance = 1000;
    129.             maxRaycasts = 100;
    130.             rayStep = 1;
    131.             coverOffset = 2;
    132.             lookAtCoverPoint = false;
    133.             rotationEpsilon = 0.5f;
    134.         }
    135.     }
    136. }

    And overlapSphereCheck is used to check if something is close to the actor
    In my case I use it to check if bullets are hitting close enough that he should seek cover.
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace BehaviorDesigner.Runtime.Tasks
    4. {
    5.     [TaskDescription("Find a place to hide and move to it using the Unity NavMesh.")]
    6.     [TaskCategory("Movement")]
    7. //    [HelpURL("http://www.opsive.com/assets/BehaviorDesigner/Movement/documentation.php?id=8")]
    8. //    [TaskIcon("Assets/Behavior Designer Movement/Editor/Icons/{SkinColor}CoverIcon.png")]
    9.     public class OverlapSphereCheck : Action
    10.     {
    11.         [Tooltip("The Layermasks to search for")]
    12.         public LayerMask layerMask;
    13.  
    14.         [Tooltip("The radius of the overlap sphere")]
    15.         public float sphereRadius = 1;
    16.  
    17.         [Tooltip("The origin of the sphere")]
    18.         public Transform origin;
    19.      
    20.         public override TaskStatus OnUpdate()
    21.         {
    22.             return Physics.OverlapSphere(origin.position, sphereRadius, layerMask).Length > 0 ? TaskStatus.Success : TaskStatus.Running;
    23.         }
    24.     }
    25. }
    26.  
     
  27. Arganth

    Arganth

    Joined:
    Jul 31, 2015
    Posts:
    277
    depending on the game
    i would rather manually mark the cover points and prefab them
    e.g. small barricade with cover points on both sides

    then you could if the agent should seek cover
    iterate through a list of all cover points

    or cache the cover points near the agent
     
  28. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I am trying to reproduce the error from your previous post. I brought in your OverlapSphereCheck task, assigned the Origin, and hit play. The task correctly ran and there weren't any errors. Are you able to reproduce the error by just bringing in this one task? If not, can you send me a PM or email with the tree so I can take a closer look? There's no need to include the base Behavior Designer package because I already have it :)
     
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    @Arganth's suggestion is what I'm doing with our next asset, the Deathmatch Kit. This allows you to specify exactly where you want a cover point to be so the agent can quickly find it and its location will always be good. I posted a gif of what it looks like in this post.
     
  30. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455

    I was thinking of that, but I sort of want the player to sort be able to just throw tanktraps out, which infantry can then use for cover, and I'm thinking just having a rigid body so they'll land on their own, that means however that I can't use predefined positions. Or at least I'd need to calculate them when they land
     
  31. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    That's exactly what you could do. When a tanktrap is thrown out you can just add it to your list of cover points.
     
    Arganth likes this.
  32. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    Hmm, somehow I thought, that would be a silly way to do it, without considering the how. Actually that would be a really easy thing to set up.
    Cheers =)
     
    opsive likes this.
  33. PixelKnights

    PixelKnights

    Joined:
    Feb 24, 2016
    Posts:
    15
    Hi all,

    I just stumbled on this asset and it looks really good. I've been playing with RAIN the past few days and find it somewhat unreliable and unwieldy. I'd reverted to writing my own AI scripts for my in-progress game but tempted to try this out, before I fork out my hard-earned cash I'm wondering if you think it would be suitable for what I'm using.

    I'm using darktonic core gamekit, spawning 100's of monsters on my map.at the moment I've setup a system where I have a number of waypoints on the map, myu monsters all pick a random waypoint head there, then re-roll and pick another etc. They all have spherical collider triggers on them which are quite big and when they detect player in that they head towards it, all very simple.

    I've checked the intro videos to Behavior Designer and all seems it wouldn't be an issue, although couldn't see anything about picking a random waypoint, does it do that or would I have to code that in myself?

    One other thing I wanted to introduce was friendly npc's in my game and the monsters to attack those and them for run away in random directions away. Again I'm sure it's do-able, guess I just wanted to make sure this all works nicely with coregamekit poolboss etc as there doesn't seem to be a trial/lite version of this asset.

    Thanks
     
  34. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Thanks for considering Behavior Designer!

    100's of agents is no problem - you'll hit other bottlenecks before Behavior Designer is the bottleneck. In fact, somebody recently did a stress test with more than a hundred units wandering around:

    https://twitter.com/syscrusher1709/status/718261272240910343
    https://twitter.com/syscrusher1709/status/718262155372601344

    The Patrol task can pick a random waypoint so that's built in.

    The Flee task will move the agent in the opposite direction, if you want a true random direction you could use the Wander task but in this case it sounds like the Flee task would be more appropriate.
     
    99thmonkey likes this.
  35. PixelKnights

    PixelKnights

    Joined:
    Feb 24, 2016
    Posts:
    15
    Hi Justin,

    Thank you so much for your reply, it certainly sounds like it ticks all the boxes, I'll go buy a copy now :)
     
    opsive likes this.
  36. PixelKnights

    PixelKnights

    Joined:
    Feb 24, 2016
    Posts:
    15
    I've bought a copy now, do I need to do anything else to get the move pack which it says is free atm?
     
  37. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Awesome - I just sent you a reply to your email :)
     
    PixelKnights likes this.
  38. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    It seems to be a bug on WithinDistance.cs of MovementPack.

    Code (csharp):
    1.  
    2.         public override void OnStart()
    3.         {
    4.             // if objects is null then find all of the objects using the objectTag
    5.             if (!string.IsNullOrEmpty(objectTag.Value)) {
    6.                 var gameObjects = GameObject.FindGameObjectsWithTag(objectTag.Value);
    7.                 objects.Value = new List<Transform>();
    8.                 for (int i = 0; i < gameObjects.Length; ++i) {
    9.                     objects.Value.Add(gameObjects[i].transform);
    10.                 }
    11.             }
    12.  
    13.             if (targetTransform != null) // Should be changed like this 'if (targetTransform.Value != null)'
    14.             {
    15.                 objects.Value = new List<Transform>();
    16.                 objects.Value.Add(targetTransform.Value);
    17.             }
    18.         }
    19.  
    targetTransform is SharedVairable so it can be null, so it should be check with its Value variable.

    -Kim
     
  39. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Are you using the most recent version of the Movement Pack? The current version doesn't have a targetTransform variable.
     
  40. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    Sorry for confusing. Yes, no transformTarget is at there.

    -Kim
     
  41. Smokas

    Smokas

    Joined:
    Mar 7, 2016
    Posts:
    114
    Started yesterday to play with Designer - the more I use the more I like it :)
    One wish - would be possible to include the some kind of "get children list" task? I use EasyRoads3D - sometimes it generates a lot of waypoints as road children.
    The task is simple IMO:

    Code (CSharp):
    1. using UnityEngine;
    2. using BehaviorDesigner.Runtime;
    3. using BehaviorDesigner.Runtime.Tasks;
    4.  
    5. [TaskCategory("Basic/Transform")]
    6. [TaskDescription("Gets children of Target into GameObject list. Returns Success.")]
    7. public class GetChildren : Action
    8. {
    9.     public SharedGameObject targetGameObject;
    10.     [RequiredField]
    11.     public SharedGameObjectList storeValue;
    12.  
    13.     public override void OnStart()
    14.     {
    15.         if (null != targetGameObject && null != targetGameObject.Value)
    16.         {
    17.             storeValue.Value.Clear();
    18.             foreach(Transform t in targetGameObject.Value.transform) {
    19.                 storeValue.Value.Add(t.gameObject);
    20.             }
    21.         }
    22.     }
    23.  
    24.     public override TaskStatus OnUpdate()
    25.     {
    26.         return TaskStatus.Success;
    27.     }
    28. }
     
  42. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    Sure, I'll add it to the next version. Your task looks good though.
     
    hopeful likes this.
  43. Smokas

    Smokas

    Joined:
    Mar 7, 2016
    Posts:
    114
    Hi Justin,

    FYI only. Unity 5.4 is comming - tried to import Designer package and got error:

    GetString is not allowed to be called from a ScriptableObject constructor (or instance field initializer), call it in OnEnable instead. Called from ScriptableObject 'FGCodeWindow'.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEditor.EditorPrefs:GetString(String, String)
    ScriptInspector.FGCodeWindow:.cctor() (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGCodeWindow.cs:244)
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    That warning looks like it's from ScriptInspector, not Behavior Designer :) Behavior Designer should be ready for 5.4.
     
  45. Smokas

    Smokas

    Joined:
    Mar 7, 2016
    Posts:
    114
    I moved code from constructor to OnEnable method - error disappeared. I use 5.4b15
     
    Last edited: Apr 22, 2016
  46. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    I would let @Flipbookee know - chances are he already has it fixed. FGCodeWindow is related to ScriptInspector.
     
  47. Smokas

    Smokas

    Joined:
    Mar 7, 2016
    Posts:
    114
    Yes - you absolutely right :) - I saw only Gaia and Designer folders - ScriptInpector was "hidden" inside Plugins :) Very sorry for false alarm. Yesterday I discussed with @Flipbookee about Retina support in 5.4 and I installed Inspector. Sorry :(
     
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,093
    No worries - it's all good :)
     
  49. Smokas

    Smokas

    Joined:
    Mar 7, 2016
    Posts:
    114
    BTW Designer + Inspector = very powerfull package IMO :)
     
    opsive likes this.
  50. Smokas

    Smokas

    Joined:
    Mar 7, 2016
    Posts:
    114
    Hi Justin

    Is here simple way to have camera follow functionality? In C# is simple:

    Code (CSharp):
    1.     void Start ()
    2.     {
    3.         offset = transform.position - player.transform.position;
    4.     }
    5.  
    6.     void Update ()
    7.     {
    8.         transform.position = player.transform.position + offset;
    9.     }
    With Designer it was needed for me to create 2 sequences with setters and getters and one repeater.