Search Unity

AI Behaviors Made Easy! (Walker Boys)

Discussion in 'Assets and Asset Store' started by profcwalker, Apr 22, 2012.

  1. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    First, thanks for buying AI Behavior! You'll likely be able to keep your animation controller, but depending on what you need it to do, you might need to make some adjustments to the CharacterAnimator, but maybe not. It's very difficult to gauge it without seeing the actual setup.

    As far as a circling around behavior, let me see if we can whip up a state for that, it doesn't seem too difficult.

    If you need to speak with me directly, you can email me at nathan@nathanwarden.com
     
  2. gringan

    gringan

    Joined:
    Oct 27, 2016
    Posts:
    42
    Hello, thx for reply.

    I just sent you an email.
    It would be very nice if you could help :)

    Regards.
     
  3. C_p_H

    C_p_H

    Joined:
    Nov 24, 2014
    Posts:
    153
  4. lundon

    lundon

    Joined:
    Nov 6, 2009
    Posts:
    59
    Listed as free. Have you guys thrown in the towel?
     
  5. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hey Guys,

    As of today we are officially making AI Behavior free on the Unity Asset store. We hope that removing the barrier to entry will entice more folks to give it a try and enjoy the process of making AI easy for game development.

    It has been an awesome experience bringing a unique process and workflow to AI development and as our commitments draw us away from active development on AI Behavior Made Easy we are going to (very soon) open source this project and build a public team around its development.
    For those who have been supporters, we thank you for your help along the way and look forward to seeing you in the open source space!

    The project is located at: https://github.com/NathanWarden/ai-behavior
     
    Last edited: Dec 6, 2018
  6. theonerm2

    theonerm2

    Joined:
    Dec 7, 2018
    Posts:
    5
    I'm new to unity and can't figure out how to make the AI move around. It animates but it just walks in place.
     
  7. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Make sure any geometry you want the AI to navigate is marked as static. You can make it navigation static only if you'd like, but typically just checking the box once so that all static modes are enabled is ideal.

    Next, open the navigation tab (you'll find it under the Window menu). Click "Bake", then try and run it again :)
     
  8. theonerm2

    theonerm2

    Joined:
    Dec 7, 2018
    Posts:
    5
    I figured out the problem. It was my animation controller. I didn't have it set up correctly. I copied this file MecanimAnimatorController.controller and then I set it up using my own animations. The problem now is it won't change direction. It just walks endlessly in 1 direction. It will change direction if I use the controller without my animations but I can't seem to be able to use my animations.
     
    NathanWarden likes this.
  9. theonerm2

    theonerm2

    Joined:
    Dec 7, 2018
    Posts:
    5
    OK now I figured out how to properly use the animations and make my character move where I want. But Now I'm trying to figure out the attack/health system.
     
    NathanWarden likes this.
  10. Zeroldea

    Zeroldea

    Joined:
    Dec 9, 2018
    Posts:
    3
    Hi i have a problem when i use the A.I with MelleeAttack: The console say,
    NullReferenceException: Object reference not set to an instance of an object
    AIBehavior.AIBehaviors.Update () (at Assets/AIBehavior/Plugins/AIBehaviorsMadeEasy/AIBehaviors.cs:247)
    Please help me
     
  11. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    @theonerm2 Take a look at the "10_state_got_hit" scene. As you shoot at the player it receives damage. This is because a projectile called "HittingProjectile" is shot and uses the MonoBehaviour's SendMessage method.

    So basically, you can call aiObj.SendMessage("Damage", amount); where *amount* is a float

    @MrZ0bal This was a bug. git pull the latest and this should be fixed. :)
     
  12. Zeroldea

    Zeroldea

    Joined:
    Dec 9, 2018
    Posts:
    3
    Thanks you for the reply
     
  13. Zeroldea

    Zeroldea

    Joined:
    Dec 9, 2018
    Posts:
    3
    How make an update of the package ? I'm sry i'm a rookie for this software
     
  14. theonerm2

    theonerm2

    Joined:
    Dec 7, 2018
    Posts:
    5
    Thanks. I've figured out how to do pretty much anything I want to do now.
     
  15. Cosmas

    Cosmas

    Joined:
    Jan 9, 2010
    Posts:
    133
    Seems to be an issue with 2018.3.1f1 whereby Triggers list is completely empty, even on a fresh character setup via the Unity context menu. Going to try to update to see if maybe it fixes it?

    http://imgur.com/G13IypU

    Update: Derp - My fault, I didn't have the editor scripts in the Assets/Editor folder.
     
    Last edited: Jan 27, 2019
    NathanWarden likes this.
  16. AdamoBranz

    AdamoBranz

    Joined:
    Feb 18, 2019
    Posts:
    1
    Hello everyone, I would like to create a card game, similar to Rummy / Scala40, this asset is right for me?
     
  17. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Thanks for your interest! This system would likely get more in your way for this type of game as it's primarily meant for 3D (or 2D) enemies or NPCs.
     
  18. Pychatasm

    Pychatasm

    Joined:
    Mar 13, 2018
    Posts:
    4
    I tried searching the thread for answer but couldn't find one quickly - is it possible to make a custom, boolean "AI Behavior Variable" drive a Mecanim Animator boolean parameter? I'm trying to make it so that upon the death state it sets a custom variable to transition to the death animation. I feel like having an "isDead" custom variable directly driving the "isDead" animation parameter should be simple and I'm just missing something. The system isn't letting me just assign an animation to the state without a transition for some reason, either.

    On that note, I'd also like to ask if there's a way, outside of a separate health code, that I could have the Dead state remove a GameObject child of the root AI? There's options to destroy the root gameobject, the colliders, and components of your choice, but they delete the Transform of the GameObject that I want to destroy, which Unity aptly tells me through the console is not allowed.
     
  19. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    I might add this at some point in the future, but for now you'll probably need to use the AIBehaviors
    onStateChanged callback and check whether the new state is the dead state and then update the variable through code.

    I'm not sure how familiar you are with scripting, so please let me know if you need additional help with this.

    I just wrote and uploaded a way for you to define arbitrary game objects you want to destroy when entering the dead state. This might be incompatible depending on which update version of AI Behavior you have.

    https://raw.githubusercontent.com/N...I_Behavior/Assets/Scripts/States/DeadState.cs

    Thanks!
    Nathan
     
  20. Pychatasm

    Pychatasm

    Joined:
    Mar 13, 2018
    Posts:
    4
    Wow, didn't expect such a fast response much less a written coded solution.
    I've been following coding tutorials off and on for a few years now, but I've yet to do much beyond modifying other's code. I'm more of an artist/animator.
    T̶h̶a̶t̶ ̶b̶e̶i̶n̶g̶ ̶s̶a̶i̶d̶,̶ ̶I̶ ̶a̶s̶s̶u̶m̶e̶d̶ ̶I̶'̶d̶ ̶i̶n̶s̶e̶r̶t̶ ̶t̶h̶e̶ ̶c̶o̶d̶e̶ ̶y̶o̶u̶ ̶o̶f̶f̶e̶r̶e̶d̶ ̶i̶n̶t̶o̶ ̶t̶h̶e̶ ̶m̶a̶i̶n̶ ̶A̶I̶B̶e̶h̶a̶v̶i̶o̶r̶s̶ ̶s̶c̶r̶i̶p̶t̶,̶ ̶e̶s̶p̶e̶c̶i̶a̶l̶l̶y̶ ̶c̶o̶n̶s̶i̶d̶e̶r̶i̶n̶g̶ ̶U̶n̶i̶t̶y̶ ̶i̶s̶ ̶g̶i̶v̶i̶n̶g̶ ̶m̶e̶ ̶t̶h̶e̶ ̶e̶r̶r̶o̶r̶:̶ ̶"̶T̶h̶e̶ ̶n̶a̶m̶e̶s̶p̶a̶c̶e̶ ̶'̶A̶I̶B̶e̶h̶a̶v̶i̶o̶r̶'̶ ̶a̶l̶r̶e̶a̶d̶y̶ ̶c̶o̶n̶t̶a̶i̶n̶s̶ ̶a̶ ̶d̶e̶f̶i̶n̶i̶t̶i̶o̶n̶ ̶f̶o̶r̶ ̶'̶D̶e̶a̶d̶S̶t̶a̶t̶e̶'̶"̶ ̶b̶u̶t̶ ̶t̶h̶e̶r̶e̶'̶s̶ ̶n̶o̶w̶h̶e̶r̶e̶ ̶I̶ ̶c̶a̶n̶ ̶f̶i̶n̶d̶ ̶d̶e̶f̶i̶n̶i̶n̶g̶ ̶a̶ ̶D̶e̶a̶d̶S̶t̶a̶t̶e̶ ̶i̶n̶ ̶t̶h̶e̶ ̶o̶r̶i̶g̶i̶n̶a̶l̶ ̶s̶c̶r̶i̶p̶t̶.̶ ̶I̶ ̶a̶m̶ ̶u̶s̶i̶n̶g̶ ̶t̶h̶e̶ ̶v̶e̶r̶s̶i̶o̶n̶ ̶a̶v̶a̶i̶l̶a̶b̶l̶e̶ ̶o̶n̶ ̶t̶h̶e̶ ̶A̶s̶s̶e̶t̶ ̶S̶t̶o̶r̶e̶,̶ ̶c̶o̶u̶l̶d̶ ̶t̶h̶a̶t̶ ̶b̶e̶ ̶t̶h̶e̶ ̶i̶s̶s̶u̶e̶?̶

    I've worked a bit with driving animations with inputs for the player character, but I'm not exactly sure how to go about having the scripts reference each other for the onStateChanged.
    EDIT: Whoops! Sorry, just realized there are individual scripts for each state, my bad.
     
  21. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    So, for the onStateChanged callback you'll probably just want to check to see if the state it just changed to is a particular state, then react appropriately. The code below is incomplete and might contain errors since I'm writing this directly into the forum:

    Let me know if that gets you in the right direction :)

    Code (CSharp):
    1. using AIBehaviors;
    2.  
    3. public class MyAnimationVariableUpdater : MonoBehaviour
    4. {
    5.      AIBehavior aiBehavior;
    6.  
    7.      void Awake()
    8.      {
    9.           aiBehavior = GetComponent<AIBehavior>();
    10.           aiBehavior.onStateChanged += OnStateChanged;
    11.      }
    12.  
    13.  
    14.      void OnStateChanged(BaseState newState, BaseState oldState)
    15.      {
    16.           if (newState is DeadState)
    17.           {
    18.                // Set variable here...
    19.           }
    20.      }
    21. }
     
    Last edited: Mar 2, 2019
  22. Pychatasm

    Pychatasm

    Joined:
    Mar 13, 2018
    Posts:
    4
    I think I understand this, and if I do it will come in VERY handy for more than just this particular issue, thank you! But, Unity is giving me errors with "using AIBehaviors" and "AIBehavior aiBehavior", changing the former to "using AIBehavior" (sans the "s") gets rid of a few errors, but it's still saying "'AIBehavior' is a 'namespace' but a 'type' was expected", referring to line 8:
    "AIBehavior aiBehavior;"
     
  23. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Oops, I wrote those backward :)

    using AIBehavior;

    GetComponent<AIBehaviors>();
     
  24. Pychatasm

    Pychatasm

    Joined:
    Mar 13, 2018
    Posts:
    4
    Okay, yes perfect! Thank you so much! This has helped a lot and will help me going forward.
     
    NathanWarden likes this.
  25. SeriousDonut

    SeriousDonut

    Joined:
    Mar 15, 2013
    Posts:
    3
    I noticed a very strange discrepancy between images of the AIBehavior component found in the documentation and what it looks like in my Unity Inspector. RaycastLayers, useSightFalloff, sightFOV, sightDistance, EyePosition are all missing from the Inspector despite being defined as public in AIBehaviors. The only items under 'General AI Properties' for me are: AI Transform, Show Debug Messages, Keep Agent Upright, Health, Max Health, AI Behavior Variables, and AI Target Tags.

    I made a new project and imported the package fresh to see if I had maybe accidentally changed something somewhere, but it was missing there as well.

    I am using Unity version 2018.3.7f1

    -EDIT-

    Oh, it turned out that in AIBehaviorsEditor.cs, all code putting the properties on the GUI was commented out. I removed the comment tags, and now it works fine it seems. Why was this commented out by default, out of curiosity?
     
    Last edited: Mar 15, 2019
    NathanWarden likes this.
  26. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Thanks, I've updated the asset store package as well with some other various fixes :)
     
  27. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    64
    A* would be great to include GRID based games. Any chance you include it? today there is NONE available with playmaker support.
     
  28. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Hi,
    I'm new to this asset and I'm really impressed. But I have one problem. I have my AI wandering around and fleeing when the player is in sight. This works quiet well, but from time to time the AI stops moving in wander state after flight although navmesh agent has speed greater 0. Any suggestions?
     
  29. franky_li

    franky_li

    Joined:
    Aug 8, 2016
    Posts:
    163
    Found the problem myself. There is a bug in WanderState.cs line 142. It tries to find a point close to anchor point even if that is switched off and not set.
    Code (CSharp):
    1. if (Vector3.Distance(hit.point, anchorPoint.position) > maxDistanceFromAnchor)
    It should be changed to:
    Code (CSharp):
    1. if (stayCloseToPoint && Vector3.Distance(hit.point, anchorPoint.position) > maxDistanceFromAnchor)
    Now it works like a charm:)
     
  30. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Ah, thanks for spotting that. I'll be sure to add that fix into the project.
     
  31. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    131
    I just started using this again after a while. I noticed my projectiles aren't moving for the ranged attack. They just spawn and they don't move.
     
  32. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    131
    I figured out that I needed the example projectile script of the projectile. Another problem though. After about 11 or so projectiles it stops shooting them.
     
  33. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    131
    I figured it out. I was supposed to use the prefab from my assets folder rather than using a gameobject in my scene.
     
  34. theonerm2_unity

    theonerm2_unity

    Joined:
    Sep 7, 2018
    Posts:
    131
    Hey. How would I go about making this work with a different asset? I have horror fps kit and it has guns and axes and stuff. I don't know how to make the weapons do damage to the ai. I'm thinking I might need to see how the attacks work in the scripts and then write another script that does damage to the ai.
     
  35. holyfot

    holyfot

    Joined:
    Dec 16, 2016
    Posts:
    42
    Small bug in 2019.2.8f1. You cannot see the + or minus buttons.
     
  36. holyfot

    holyfot

    Joined:
    Dec 16, 2016
    Posts:
    42
    Actually this only happens if you move the AIBehavior folder.
     
    CakeMuffinCo likes this.
  37. mbhagat

    mbhagat

    Joined:
    Dec 15, 2013
    Posts:
    49
    Hi,
    My Game FPS is dropped to 30 -33 if I use this asset.
    Why too much frame rate drop ?
    Is AI too heavy for mobile ?
     
  38. Muralidaran

    Muralidaran

    Joined:
    May 2, 2014
    Posts:
    93
    Has anyone figured out how to get the Got Hit state to work with Opsives UCC? They no longer use the vp_damagehandler in ufps 2
     
  39. oliver_unity892

    oliver_unity892

    Joined:
    Oct 28, 2019
    Posts:
    91
    Hi

    Does the ai behaviours made easy asset support 2d? The examples appear to all be 3d but I'd like to use it in a top down.

    Olly
     
  40. Marks_M

    Marks_M

    Joined:
    Nov 12, 2021
    Posts:
    27
    Hello Nathan, I really hope this thread is still active! I just want to say I love your work and that I use Ai Behaviors for my game development! I was going to ask you how can I stop Ai from becoming forced into the corners of a map when it's fleeing , so it doesn't look like it's "running in place". How can I start improving the flee state, so it's more dynamic - so there's no "forcing into the corner" and "running in place" when it's fleeing from the player? Please help me out!
     
  41. Slisler

    Slisler

    Joined:
    Jan 5, 2022
    Posts:
    1
    Is there any way to use visual scripting for the attack state? It says that is does not detect any javascript or c# components.
     
  42. hugo-purespark

    hugo-purespark

    Joined:
    Oct 29, 2022
    Posts:
    15
    Hi Great tool, but I'm a bit stuck. My AI works perfect going from ide to wonder and then if the payer is close it will go to seek and then melee attack when it reaches the player. The only issue is that the AI will move right into the player. I've tried setting the threshold distance but has no effect.
     

    Attached Files:

  43. JeffG

    JeffG

    Joined:
    Oct 21, 2013
    Posts:
    85
    Try changing the stopping distance on the navmesh agent
     
  44. hugo-purespark

    hugo-purespark

    Joined:
    Oct 29, 2022
    Posts:
    15
    Thanks this worked somewhat. The character stops at the correct distance but then it does not go into the attack animation. I guess all the settings must be at a sweet spot so everything works together.

    I ended up making the box collider on the enemy higher so that it pushes the player backwards on attack which keeps the player at the correct distance. The only drawback is because the player only moves a small distance when the enemy attacks the enemy moves forward without going into the walk animation, so its sort of a attack slide forward movement.