Search Unity

Behavior Designer - Behavior Trees for Everyone

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

  1. Eriks-indesign

    Eriks-indesign

    Joined:
    Aug 15, 2012
    Posts:
    50
    Thank you so much! You are gods gift to noob kind :D
     
    opsive likes this.
  2. ocimpean

    ocimpean

    Joined:
    Aug 10, 2013
    Posts:
    128
    I was reading the posts on the forum and it seems to me that people are using BED mainly for FPS enemy AI creation.
    Could you reccomend Behavior Designer (maybe with Motion or another pack?) for a virtual pet project or would be overkill?
     
  3. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Behavior trees are used in a wide variety of games. They gained their popularity with Halo 2 but aren't restricted to any genre. For a virtual pet you could use behavior trees to help decide when the pet should eat, sleep, or go exercise. In fact, this is really similar to the utility theory sample project that we have where the agent uses the Utility Selector task to decide if they should eat, work or sleep. So yes, you can definitely use behavior trees with a virtual pet :)
     
  4. ocimpean

    ocimpean

    Joined:
    Aug 10, 2013
    Posts:
    128
    Thank you for the fast reply. Is this sample project included in Behaviour Designer or I have to get one of the extension packs?
     
  5. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    That sample project is included, available at http://www.opsive.com/assets/BehaviorDesigner/samples.php with an invoice number.

    For a virtual pet the Movement Pack would probably also make sense so they can easily move from point to point.
     
    ocimpean likes this.
  6. ocimpean

    ocimpean

    Joined:
    Aug 10, 2013
    Posts:
    128
    Then I will have to buy both ;)
     
    opsive likes this.
  7. Eriks-indesign

    Eriks-indesign

    Joined:
    Aug 15, 2012
    Posts:
    50
    With very limited coding knowledge how would I go about using SensorToolkit without this?
     
  8. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    I haven't used SensorToolkit before but it'll most likely take some type of integration. You may be able to use the Invoke Method task to call a SensorToolkit method (using reflection), but to do it properly it'll take some type of integration which will require a new set of tasks.

    It looks like SensorToolkit has a set of Playmaker actions and you could use those as a model for the Behavior Designer tasks since the structure is very similar.
     
  9. Eriks-indesign

    Eriks-indesign

    Joined:
    Aug 15, 2012
    Posts:
    50
    I only reason I want to use SensorToolkit is because it seems like the withinsight of behavior is not very accurate. My behaviour tree looks like this: http://imgur.com/a/8tBlM and it's a pet AI where it will fetch the ball if in sight but it only sometime sees the ball despite me placing it right in front of the pet.
     
  10. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Are you referring to Within Distance or Can See Object? With Can See Object if it's not detecting an object that you think that it should then chances are something else got in the way when it is performing the raycast. This can include the ground. One way to solve this is to set a small y offset value on the Can See Object task so the raycast doesn't start below the ground (this raycast starts/ends based on the object's pivot position).
     
  11. Eriks-indesign

    Eriks-indesign

    Joined:
    Aug 15, 2012
    Posts:
    50
    Yet again! thank you! legend! :D
     
    opsive likes this.
  12. CoMANDOR

    CoMANDOR

    Joined:
    Sep 21, 2015
    Posts:
    8
    Hi. This asset support AI for 2D game (x,y) and without addons (different packs)?
     
  13. appetizermonster

    appetizermonster

    Joined:
    Sep 15, 2015
    Posts:
    11
    Hey @opsive, I was trying to join your forum(opsive.com) with my email, but I couldn't get an activation email. (not even in a spam box)
    please activate my account on your forum.

    and I found a critical bug when i'm using it.
    I made a my custom Action Task, which has `public Action[] someOtherTasks` as a instance variable.
    and I placed this action task in the behavior tree, and assign some other action tasks to it.
    and then it cannot be deleted with (internal OutOfIndex error)

    I'll send you a simple reproduction project if you want.
     
  14. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Yes - behavior trees by themself don't care if you're creating a 2D or a 3D game. The flow itself is the same. Where it really starts to matter is when you add tasks to the behavior tree. For some tasks, such as pathfinding ones, the plane orientation can matter. Prior to Unity 5.6 the Movement Pack tasks weren't able to use Unity's NavMesh for 2D games. With Unity's recent update you can now do pathfinding on any plane so this is no longer a restriction.

    Hope that helps!
     
  15. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    What is the username that you registered with on the opsive forums?

    I just tried to reproduce that error but wasn't able to - are you running the latest version? There were some changes related to this in the last update. If you are running the latest a repro scene would be great - can send it via PM or to support@opsive.com?
     
  16. appetizermonster

    appetizermonster

    Joined:
    Sep 15, 2015
    Posts:
    11
    my username is "appetizermonster", and I just got confirmed my account has been activated. (it seems your mail IP has been blocked by my mail provider)

    installed behavior designer's version is v1.5.9(latest for now). and it still produces the error like the below one.
    I'll send you a reproduction project.

    upload_2017-5-19_9-57-9.png
     
  17. TalkieTalkie

    TalkieTalkie

    Joined:
    Jul 5, 2012
    Posts:
    123
    Can Behaviour Designer be used to create AI for Adventure Creator (with or without UFPS)? I am not creating third person game, just curious if in FPS mode (even without UFPS) can it be used with Adventure Creator?

    Thanks.
     
  18. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    The Adventure Creator integration with Behavior Designer has a set of Adventure Creator actions which you can use the start/stop a behavior tree. Those actions will work in any perspective.
     
  19. TalkieTalkie

    TalkieTalkie

    Joined:
    Jul 5, 2012
    Posts:
    123

    OK thanks, just bought Behavior Designer cause of that.
     
    opsive likes this.
  20. Chrisad

    Chrisad

    Joined:
    Mar 12, 2013
    Posts:
    55
    Hello Opsive. I contacted you about huge loading time made by the instanciation of gameobjects with big behavior trees on it in april. Do you have make any changements since that day? (there isnt any new version of BD since february).
     
  21. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Are you using binary serialization? I looked into it and storing a copy of the deserialized object won't improve the speed because copying the object from memory to a new tree takes just as long as running the binary deserialization process. If you are using JSON deserialization there is a speed improvement but I don't recommend using JSON if you're going for speed (it's great during development so you can merge in the changes though!).
     
  22. Chrisad

    Chrisad

    Joined:
    Mar 12, 2013
    Posts:
    55
    I use binary serialization. You can reproduce the problem easily: just make an external behavior with a lot of tasks (50+), assigned it to a gameObject and duplicate it 50 times. When I investigate the problem, UTF8 Encoding string methods take a lot of time and was the major issue.
     
  23. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Can you send me a PM with the tree that you are using?

    Edit: Is your tree running the latest binary serialization? Prior to 1.5.7 the binary serialization would do string concatenation but that is no longer the case as of the latest version. This could be what you are seeing with the string methods.
     
    Last edited: May 23, 2017
  24. spvn

    spvn

    Joined:
    Dec 10, 2013
    Posts:
    80
    Hey @opsive you've mentioned multiple times in this thread that you guys don't recommend directly managing animations through the behaviour tree, and should instead play animations based on e.g. the velocity of a character. However, what about stuff like "attacking" or "shooting" animations? How do these fit into such a system? None of the links you've provided so far seem to address this issue. (e.g. walk to spot -> attack -> continue wandering)
     
  25. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    You're referring to this page, right? It does only mention movement but attacking or shooting animations should be managed through the character controller as well. This will allow the most flexibility in your behavior tree because you don't need to worry about managing animation state. In your character controller it may be as simple as setting a bool parameter within the animator controller but as your character controller grows this make things a lot easier.
     
  26. spvn

    spvn

    Joined:
    Dec 10, 2013
    Posts:
    80
    Sorry I don't understand what you mean by that. My current situation is as such.

    I have an enemy's animation that charges and then shoots. A few questions.

    1. If triggering the animation from the tree isn't the best way to do this, what is? E.g. I'll have an "start attack charge" node in the tree. What should this node do to trigger the animation?
    2. After the enemy is done charging, I want to shoot a projectile at the correct time. Thus I'll likely use an animation event for this. In the tree, I'll have a "shoot" node that's responsible for creating the projectile. How can the node be fired at the right time (i.e. midway through the animation via an animation event?)
    3. After the enemy is done shooting, I want it to resume "wandering" or just moving to another place. This "wander" or "move" script will be another node in the tree. How will this node be able to know when the attack animation has completed so that they can execute? (i.e. I need to communicate back to the tree that a particular animation in the gameobject's animator is done playing)
    Hope these questions can be answered. Thanks.
     
  27. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    The character controller that you are using should do the triggering of the animation. This way it can listen for the animation event when the projectile can be fired and can tell the animator controller to transition to the next node.

    You could use the event system to tell the behavior tree when it can move.

    Basically what I recommend is moving all of the non-AI stuff out of the behavior tree and let the character controller handle that. Using this method it makes it really easy to handle just the controller logic - such as knowing when to fire the weapon. The behavior tree should tell the controller to fire the weapon, but then it's up to the controller to do the actual firing.
     
  28. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hello Folks,

    I just bought BDesigner and I'm really loving it so far.

    I'm working in a multiplayer game using UNET. And I started thinking of integrating BD with my game.

    The most obvious way will let the server execute all the AI and make the AI character sync by using NetworkTransform + network animator (this is also what I found in the exemples in opsive website) but I don't think that is the best way (if having multiple AI=> huge bandwidth consumption due to rigid body sync... , Ai mouvement will look laggy on client due the network transform optimizations....)

    The other way that I'm thinking of is the execute the AI in both server and client and sync all the decisive event (next waypoint, isattacking player...). This approach dosnt need the use of network transform since the path finding solution is executed on all clients/server, and server will be only responsible for sending the next position to reach for exemple...
    this approach will give a more "fluid" AI movement but will need some heavy code rewrite of all the existing scripts in movement pack for exemple (syncing way points, syncing seek positions...). Probably I'm missing other cons in this solution too...

    What's your advices/best practices of using BDesigner with UNET (or any other networking solutions) ?


    Thank you
    (Sorry for my English cause I'm French and I was very bad at school :p )
     
    Last edited: Jun 7, 2017
  29. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    You're working with a server authoritative network, correct? For that I recommend that you take an approach similar to the first one with some modification: run the behavior tree on the server, and just send back the resulting positions/rotations/animations. This will allow all clients to sync correctly while sending the minimal amount of data between instances.
     
  30. LunguM

    LunguM

    Joined:
    Jul 19, 2012
    Posts:
    17
    I'm on the fence a bit so I'd like some clarification if possible.

    I've been looking into Behavioral Trees after I realized that FSM's and SO's are not going to cut it for the type of AI I want to implement.

    I've already implemented spaceship logic (movement / avoidance / etc) using SFM's and SO's, so what I want to know is if I would be able to transition my implementations into BD and continue from there. I don't use anything special for my AI other than Unity's Rigidbody for movement and ParticleSystem for effects (ie, no 3rd party software, script or api).

    Also, I do have an SO (multiple ones in fact) that hold the "original" data of a ship (its scan range, max movement speed, acceleration, turn rate, etc). Would I be able to call the values from that SO using BD?
     
    Last edited: Jun 13, 2017
  31. opsive

    opsive

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

    Thanks for taking a look at Behavior Designer! I have a guess but just so I completely understand, when you say SO what are you referring to? After that I should have a more complete answer :)
     
  32. LunguM

    LunguM

    Joined:
    Jul 19, 2012
    Posts:
    17
    ScriptableObjects. I should have specified from the start :p
     
  33. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Thanks - that is what I would have guessed but just wanted to make sure :)

    Yes - you would be able to. You could create a task which sets the destination for movement system and then have it move the space ship. This is really similar to what the Movement Pack does - it sets the destination and then lets the NavMeshAgent do the actual movement.

    Yes, you can. You may be able to use the reflection tasks depending on where you have the scriptable object loaded but I would recommend creating your own dedicated tasks for this since reflection is slower than calling the function directly. If you haven't seen it yet here's the documentation on creating a new Conditional and Action tasks
     
  34. LunguM

    LunguM

    Joined:
    Jul 19, 2012
    Posts:
    17
    Thank you for the quick reply :) I've been reading the documentation up until now and it is very impressive. I'll start porting everything I have into BD.

    Thank you once again :D
     
    opsive likes this.
  35. Brechtos

    Brechtos

    Joined:
    Sep 18, 2014
    Posts:
    18
    Any news on this ? I tried adding it in myself using the ObjectDrawer as is but seem to be missing some information on how I would be able to pull this off with the current options available.
    A HeaderAttribute and SpaceAttribute would greatly help in keeping more extended custom nodes clean and user friendly. Besides that, loving BD, on of the most polished and solid unity plugins out there!
     
    TeagansDad likes this.
  36. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Very happy to hear that you're enjoying Behavior Designer!

    I haven't had a chance to add it yet, but I'll make sure it is included in the next release :)
     
  37. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    Hi Justin,

    I'm trying to use the surround in my game where wolfs attack player. For some reason when the wolfs are formed they wait (sometimes longer, sometimes shorter time) and then run into the player. I only want the wolfs to surround the player and not to run over the player. Any idea what could cause this?

     
  38. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    What is your attack distance set on the IAttackAgent interface set to? After all of the wolves have arrived at their destination they start to attack, and if this attack distance is small then they'll move into the target.
     
  39. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    I modified the shootable.cs script and each wolf has this script. I set the attackDistance to high value like 100 but they still attack. How could I disable the attact from surround? So they would only surround the player?

    Code (csharp):
    1. using UnityEngine;
    2.  
    3. namespace BehaviorDesigner.Runtime.Tactical
    4. {
    5.  
    6.     public class wolfScript : MonoBehaviour, IAttackAgent
    7.     {
    8.         // The furthest distance that the agent is able to attack from
    9.         public float attackDistance;
    10.         // The amount of time it takes for the agent to be able to attack again
    11.         public float repeatAttackDelay;
    12.         // The maximum angle that the agent can attack from
    13.         public float attackAngle;
    14.  
    15.         // The last time the agent attacked
    16.         private float lastAttackTime;
    17.  
    18.         /// <summary>
    19.         /// Initialize the default values.
    20.         /// </summary>
    21.         private void Awake()
    22.         {
    23.             lastAttackTime = -repeatAttackDelay;
    24.         }
    25.  
    26.         /// <summary>
    27.         /// Returns the furthest distance that the agent is able to attack from.
    28.         /// </summary>
    29.         /// <returns>The distance that the agent can attack from.</returns>
    30.         public float AttackDistance()
    31.         {
    32.            return attackDistance;
    33.         }
    34.  
    35.         /// <summary>
    36.         /// Can the agent attack?
    37.         /// </summary>
    38.         /// <returns>Returns true if the agent can attack.</returns>
    39.         public bool CanAttack()
    40.         {
    41.            return lastAttackTime + repeatAttackDelay < Time.time;
    42.         }
    43.  
    44.         /// <summary>
    45.         /// Returns the maximum angle that the agent can attack from.
    46.         /// </summary>
    47.         /// <returns>The maximum angle that the agent can attack from.</returns>
    48.         public float AttackAngle()
    49.         {
    50.             return attackAngle;
    51.         }
    52.  
    53.         /// <summary>
    54.         /// Does the actual attack.
    55.         /// </summary>
    56.         /// <param name="targetPosition">The position to attack.</param>
    57.         public void Attack(Vector3 targetPosition)
    58.         {
    59.             lastAttackTime = Time.time;
    60.         }
    61.     }
    62. }
     
  40. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    If you don't want to attack at all you can remove tacticalAgent.TryAttack() on line 60 of Surround.cs - this should then prevent the wolves from moving in.
     
  41. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    The wolfs still attacked player but I found out why. My problem was with Nav Mesh Agent values. My Stopping Distance was 1 and I changed it to 0. My Base Offset 0 and I set it to 0.2 and the problem went away.
     
    Last edited: Jun 30, 2017
    hopeful likes this.
  42. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    568
    Hi Justin,

    I'm just taking my first baby steps with Behavior Designer. I purchased this package when you first put it out on the asset store 4 years ago but I got sidetracked all these years - I'm delighted to finally now play with it. It's come a long way in 4 years! Very impressive development.

    I'm not the most experienced coder but I know just enough to make little things happen in Unity. I do have some Behavior Tree experience having used Angry Ant's Behave framework on several projects. I watched all your videos, read both your documentation and this entire forum thread as well as your forums on your Opsive site. So I've gleaned a lot of info this weekend - maybe too much - I may have information overload.

    With that said, I have a question about variables. Let's say I have a Player Component - a monobehavior. And in my player component I of course have methods and data that I use to make my player do things. So now I have a Behavior Tree on my player as well. I wrote a custom conditional task and a custom action task. Nothing groundbreaking - the conditional task checks to see if a target gameObject is within a player's "zone" and the action task just draws a Debug.Line from the player to the target.

    Take a quick look at my code and see how I am accessing my player's data:

    Code (CSharp):
    1. using UnityEngine;
    2. using BehaviorDesigner.Runtime;
    3. using BehaviorDesigner.Runtime.Tasks;
    4.  
    5. [TaskCategory("Hockey")]
    6. public class IsPuckInZone : Conditional
    7. {
    8.     public Player player;
    9.  
    10.     public override void OnAwake()
    11.     {
    12.         player = gameObject.GetComponent<Player>();
    13.     }
    14.  
    15.     public override TaskStatus OnUpdate()
    16.     {
    17.         Vector3 puckPositionV3 = player.puck.position;
    18.         Vector2 puckPositionV2 = new Vector2(puckPositionV3.x, puckPositionV3.z);
    19.  
    20.         Rect rect = new Rect(0, 0, player.zone.x, player.zone.y);
    21.         if (rect.Contains(puckPositionV2, true))
    22.             return TaskStatus.Success;
    23.         else
    24.             return TaskStatus.Failure;
    25.     }
    26. }
    Code (CSharp):
    1. using UnityEngine;
    2. using BehaviorDesigner.Runtime;
    3. using BehaviorDesigner.Runtime.Tasks;
    4.  
    5. [TaskCategory("Hockey")]
    6. public class PathToPuck : Action
    7. {
    8.     public Player player;
    9.  
    10.     public override void OnAwake()
    11.     {
    12.         player = gameObject.GetComponent<Player>();
    13.     }
    14.  
    15.     public override TaskStatus OnUpdate()
    16.     {
    17.         Debug.DrawLine(player.transform.position, player.puck.position);
    18.         return TaskStatus.Success;
    19.     }
    20. }
    In both tasks I am caching the player component in the OnAwake function and then using that in OnUpdate to access data such as a target transform (the puck) and a property called zone.

    It all works fine but should I be doing it that way? It means having to cache the player component in every custom task I write. Something tells me I should be using a custom sharedVariable. I tried creating a sharedPlayer variable but then could not access anything in the Player component. Probably because I'm over my head and still need to figure out custom sharedVariables.

    Any advice or links you can point me to regarding how to best access my Player Component. Or is what I'm doing okay? It seems to work just fine in this very small test case.

    Thanks for any help with this.

    Mitch
     
  43. MarkusGod

    MarkusGod

    Joined:
    Jan 10, 2017
    Posts:
    168
    Hi, can BED with movment pack be used with NavMesh runtime api, i see that movment pack can be used with some pathfinding projects and navmesh, but no information about runtime api?
     
  44. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Awesome - yeah it has been fun to watch it grow!

    What you are doing is what I recommend. If you end up using this Player component in many tasks you could inherit these player classes from a new base class:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using BehaviorDesigner.Runtime;
    4. using BehaviorDesigner.Runtime.Tasks;
    5.  
    6. public abstract class PlayerBase: Action
    7. {
    8.     public Player player;
    9.  
    10.     public override void OnAwake()
    11.     {
    12.         player = gameObject.GetComponent<Player>();
    13.     }
    14. }
    15.  
    16. using UnityEngine;
    17. using BehaviorDesigner.Runtime;
    18. using BehaviorDesigner.Runtime.Tasks;
    19.  
    20. [TaskCategory("Hockey")]
    21. public class PathToPuck : PlayerBase
    22. {
    23.     public override TaskStatus OnUpdate()
    24.     {
    25.         Debug.DrawLine(player.transform.position, player.puck.position);
    26.         return TaskStatus.Success;
    27.     }
    28. }
    29.  
    The end result will be the same. You could also use a SharedVariable to assign the Player component but in this case it would end up being more work since the Player component is on the same object as your behavior tree.
     
  45. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Yes, the Movement Pack works with the new 5.6 navmesh. There weren't any API changes that the Movement Pack uses so no changes were required in order to support it.
     
    MarkusGod likes this.
  46. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    568
    Fantastic, Justin. Yes, as I progress and scale up I will be using the Player Component quite a bit. Not being a skilled programmer, I don't quite understand all the goings on underneath with inheritance and abstract classes and override methods, but I know enough to take the advice and code snippet you have given me and alter it a bit to make it work!

    So I now have an abstract class PlayerConditional:

    Code (CSharp):
    1. using UnityEngine;
    2. using BehaviorDesigner.Runtime;
    3. using BehaviorDesigner.Runtime.Tasks;
    4.  
    5. public abstract class PlayerConditional : Conditional
    6. {
    7.     public Player player;
    8.  
    9.     public override void OnAwake()
    10.     {
    11.         player = gameObject.GetComponent<Player>();
    12.     }
    13. }
    and an abstract class PlayerAction:

    Code (CSharp):
    1. using UnityEngine;
    2. using BehaviorDesigner.Runtime;
    3. using BehaviorDesigner.Runtime.Tasks;
    4.  
    5. public abstract class PlayerAction : Action
    6. {
    7.     public Player player;
    8.  
    9.     public override void OnAwake()
    10.     {
    11.         player = gameObject.GetComponent<Player>();
    12.     }
    13. }
    14.  
    So now when create a new conditional task for my player I do this:

    Code (CSharp):
    1. using UnityEngine;
    2. using BehaviorDesigner.Runtime;
    3. using BehaviorDesigner.Runtime.Tasks;
    4.  
    5. [TaskCategory("Hockey")]
    6. public class IsPuckInZone : PlayerConditional
    7. {
    8.     public override TaskStatus OnUpdate()
    9.     {
    10.         Vector3 puckPositionV3 = player.puck.position;
    11.         Vector2 puckPositionV2 = new Vector2(puckPositionV3.x, puckPositionV3.z);
    12.  
    13.         Rect rect = new Rect(0, 0, player.zone.x, player.zone.y);
    14.         if (rect.Contains(puckPositionV2, true))
    15.             return TaskStatus.Success;
    16.         else
    17.             return TaskStatus.Failure;
    18.     }
    19. }
    and this for a Player Action:

    Code (CSharp):
    1. using UnityEngine;
    2. using BehaviorDesigner.Runtime;
    3. using BehaviorDesigner.Runtime.Tasks;
    4.  
    5. [TaskCategory("Hockey")]
    6. public class PathToPuck : PlayerAction
    7. {
    8.     public override TaskStatus OnUpdate()
    9.     {
    10.         Debug.DrawLine(player.transform.position, player.puck.position, Color.green);
    11.         return TaskStatus.Success;
    12.     }
    13. }
    The net result is I don't have to spend time to write code for a Player player variable and a GetComponent call in OnAwake for every custom task I write. A small convenience but as I write more and more custom tasks it all adds up.

    I have no idea how it all works but it does. I've changed your code a bit, so if you see anything that may be problematic please let me know.

    Thank you so very much for your excellent help. You sir, are top notch!

    Best,
    Mitch
     
  47. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    341
    Hi,

    I updated to lastest Unity 2017.1.0f3 and I'm getting over 82 of these.

    Assets/Behavior Designer Movement/Scripts/Tasks/CanHearObject.cs(7,6): error CS1614: `HelpURL' is ambiguous between `HelpURL' and `HelpURLAttribute'. Use either `@HelpURL' or `HelpURLAttribute'

    Any help how to fix this?

    Edit: Ok, I think you need to replace all the:

    [HelpURL("http://www.opsive.com/assets/BehaviorDesigner/Movement/documentation.php?id=11")]

    To..

    [@HelpURL("http://www.opsive.com/assets/BehaviorDesigner/Movement/documentation.php?id=11")]
     
    Last edited: Jul 12, 2017
  48. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    That fix would work, but are you running the latest version of Behavior Designer and the Movement Pack? I just imported into 2017.1 and did not get those warnings.
     
  49. MitchStan

    MitchStan

    Joined:
    Feb 26, 2007
    Posts:
    568
    Hey Justin,

    I've been doing great with BD, but I'm stumped with the following scenario:

    I need to share an AnimationCurve between tasks. So I successfully created a public AnimationCurve in a task and set the curve in the inspector.

    I then created a new Shared Variable called SharedParametricCurve.

    But I'm stuck there. I can't seem to figure out how to set my sharedParametricCurve to the AnimationCurve.

    Eventually I'm homing to do sharedCurve.Evalute().

    Any advice on how to set this up correctly?

    Thank you for your help.

    Mitch
     
  50. opsive

    opsive

    Joined:
    Mar 15, 2010
    Posts:
    5,127
    Hey Mitch,

    You could create a new AnimationCurve SharedVariable:

    Code (csharp):
    1.  
    2.     public class SharedAnimationCurve : SharedVariable<AnimationCurve>
    3.     {
    4.         public static implicit operator SharedAnimationCurve(AnimationCurve value) { return new SharedAnimationCurve { mValue = value }; }
    5.     }
    6.  
    This will then allow you to do sharedCruve.Value.Evaluate(). In fact I'll include this variable in the next release :)