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
    Hi Talha, I just sent you an email about this lighting issue and the headshot. This provides a bit more info. The only time I've encountered issues like this is when I either use the 32 bit editor or run out of RAM. Is the scene you're baking a large scene, or a small one?

    If nothing else, I'm not sure if you've tried putting this into another more generalized section of the Unity forums, but I'm sure if you're encountering this issue, then someone else most likely has too.
     
  2. TalhaDX

    TalhaDX

    Joined:
    Feb 2, 2013
    Posts:
    94
    I have turned off Auto Bake option in Lighting window and it has helped me make static objects. And you are right my system run out of memory and it is a 32-bit editor as well. I will upgrade it too.
     
  3. PhosphorUnity

    PhosphorUnity

    Joined:
    Jan 22, 2014
    Posts:
    39
    Wondering:

    1- is there anyway to make AI go to "last known location" of player?

    I was thinking if an Enemy was shot, that it's next patrol / seek point would be to go to the location where where the player was when the Enemy was shot. So the player could shoot an enemy and lure it to a location

    I've been able to fake a lot of behavior, but not sure how to do that one >>EDIT: actually I realize this is probably too game specific to make generic, just need to do something with dropping a seek target<<

    2- How do you make an different projectile hurt an AI? So AI can fight AI, or player to cause damage besides example script. Like similar how you define an ememie's projectile to hurt player, how do you set one to hurt them? >>EDIT: nevermind, I see you add Projectile Collider Component<<
     
    Last edited: Feb 23, 2016
  4. PhosphorUnity

    PhosphorUnity

    Joined:
    Jan 22, 2014
    Posts:
    39
    Future Behavior ideas:
    • It would be nice if there was a "back away" behavior that friendly NPC ( villagers, etc) could use. Like when players get too close, they slowly back up instead of turning and fleeing ( like a flee forward or backward checkbox) .

    • It would be nice if there was a trigger to detect # how many got hit in a row (time) , and change behavior. While you can try to disrupt this with random behaviors, it would be nice for a large creature (Troll) to stop coming towards you, if he was hit like X amount in a row . Like it is too easy to spam more "tank" creatures early on (again, baring random) , their only option is really turning around and fleeing
     
    Last edited: Mar 1, 2016
  5. PhosphorUnity

    PhosphorUnity

    Joined:
    Jan 22, 2014
    Posts:
    39
    Is there a way to make a behavior end (without timer) at end of animation (clamp) ?
     
  6. TalhaDX

    TalhaDX

    Joined:
    Feb 2, 2013
    Posts:
    94
    I have used AI Behavior in my games as well. But there are few of issues:

    1 - Enemy shoots at player feet (i changed pivots but didn't worked)
    2- When there is small distraction (barel, box etc) that covers enemy legs, it stops behaving and goes to idle. Seems it is looking at player from its feet as well, although i have set sight transform above.
    3 - Increasing sight distance doesn't effect in my recent game, i don't know why it happens.

    Someone plzz....
     
  7. Muralidaran

    Muralidaran

    Joined:
    May 2, 2014
    Posts:
    93
    Hey Nathan,

    I need a bit of help with UFPS. I have handled my own damage system but now I am having trouble getting it to go into the GotHitState. With the code below it works only as long as the bullet hits the character controller, so with enemies with long bodies(wolves,deer) that need an extra capsule collider it doesn't work. I had to attach a sphere collider trigger to the bullet object.

    Any idea what I am doing wrong? Thanks.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using AIBehavior;
    4.  
    5.  
    6. namespace AIBehaviorExamples
    7. {
    8.     public class ProjectileCollider : MonoBehaviour
    9.     {
    10.  
    11.         AIBehaviors ai;
    12.        
    13.                 void OnTriggerEnter(Collider other)
    14.         {
    15.                         if (other.tag == "Bullet") {
    16.  
    17.                                 ai = GetComponent<AIBehaviors>();
    18.                                 // This will get you the current state's name such as MyCustomFlee
    19.                                 string stateName = ai.currentState.name;
    20.  
    21.                                 // This will change the AI into using the idle state
    22.                                 GotHitState gotHitState = ai.GetState<GotHitState>();
    23.                                 ai.ChangeActiveState(gotHitState);
    24.  
    25.             }
    26.         }
    27.     }
    28. }
     
  8. Deangelo28

    Deangelo28

    Joined:
    May 10, 2016
    Posts:
    4
    Hey Nathan,
    i buyed the System yesterday and I realy loved it so far but only one issue i don't get it work with the UFPS controller tried it with the script that was in the extra folder but it doesn't work.

    Regards
    Deangelo
     
  9. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Deangelo,

    I'm helping a friend learn Unity by making a game starting tomorrow and we'll be using the UFPS controller. So, I'll see if I can download the latest UFPS tomorrow and get back with you on this.

    Thanks,
    Nathan
     
  10. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    It looks like he updated UFPS to have different damage modes. You'll need to change the damage mode on projectiles (like PistolBullet) from "Damage Handler" to "Unity Message". Let me know if you have any more trouble.

    If I get some time I'll try and at least make some basic actions this week :)
     
  11. Deangelo28

    Deangelo28

    Joined:
    May 10, 2016
    Posts:
    4
    It also works when i put the Dmg handler from UFPs on the Agent put also the respawner script on it from Ufps and the Agent can spawn now.The only issue is that the mixamo Animations when i set them to Legacy doesn't work probably it looks realy strange my Agent is skating and not goin' forward.

    Regards Deangelo
     
  12. maxmarkmorphious

    maxmarkmorphious

    Joined:
    Nov 6, 2015
    Posts:
    6
    So I need some help. Im making an rts. My solider won't fire when he enters the attack state. Here's the code. This code works for my soldiers when I order them to attack the enemy but not the other way around. What am I doing wrong?


    using UnityEngine;
    using System.Collections;
    using AIBehavior;

    publicclassTacticalAIAttack:MonoBehaviour{

    publicGameObjectBolter_Gun_Bullet;

    publicTransformWeaponTransform;

    publicTransformenemytargeted;

    publicfloatspeed=1000f;

    privateAnimatoranim;



    publicvoidStart(){

    anim=GetComponent<Animator>();

    }

    publicvoidUpdate(){

    }

    publicvoidOnAttack(AttackDataattackData){


    anim.SetBool("isFiring",true);

    GameObjectbolterbulletinstance=Instantiate
    (Bolter_Gun_Bullet,WeaponTransform.position,Quaternion.identity)asGameObject;
    bolterbulletinstance.transform.position=Vector3.MoveTowards
    (WeaponTransform.position,enemytargeted.position,Time.deltaTime*speed);

    }
    }
     
  13. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Deangelo, can you point me to which Mixamo animation pack you're using?

    You can put a debug statement in the OnAttack method. If the debug statement gets called then there's likely an issue with your Mecanim/Attack setup. If it doesn't get called then there's something wrong with your AI setup. Are you using the MecanimAttackState or the regular AttackState?

    Code (csharp):
    1.  
    2. public void OnAttack(AttackData attackData){
    3. Debug.Log("Attack!");
    4. anim.SetBool("isFiring",true);
    5.  
    6. GameObject bolterbulletinstance=Instantiate
    7. (Bolter_Gun_Bullet,WeaponTransform.position,Quaternion.identity) as GameObject;
    8. bolterbulletinstance.transform.position=Vector3.MoveTowards
    9. (WeaponTransform.position,enemytargeted.position,Time.deltaTime*speed);
    10. }
    11. }
     
  14. maxmarkmorphious

    maxmarkmorphious

    Joined:
    Nov 6, 2015
    Posts:
    6
    Hey buddy thanks for the quick reply. Its ok iv'e sorted out the problem I mentioned obove. Im using the regular attack state. Now I have another problem which I can't quite get right. Im making a turn based strategy. Every unit has action points which are spent via animation events when certain animations are called. I have it so when an attack state is called it goes to the next attack state and decrements action points approriately when the attack animations are called. I created a custom trigger which is set to trigger when the unit has below 15 actions points. The trigger goes to a custom state called 'unit turn finished' which has nothing inside it at the moment. The problem is that when the unit drops below 15 action points I get an error saying

    NullReferenceException: Object not set to an instance of an object
    'LowAPTrigger.Evaluate (AIBehaviour.AIBehaviours fsm)at Assets/AIbehaviour/Plugins/AIBehaviourMadeEasy/Triggers/LowAPTrigger.cs:21)

    The idea is that an attack state will change into a unit turn finished state if there is below 15 action points. The action points are stored as an int and are represented by a world space canvas positioned above the unit.

    Heres the ap trigger script:

    using UnityEngine;
    using AIBehavior;
    using System.Collections;

    #ifUNITY_EDITOR
    using UnityEditor;
    #endif


    publicclassLowAPTrigger:BaseTrigger
    {

    APManagerapmanager;

    voidStart(){
    apmanager=GetComponent<APManager>();
    }

    protectedoverrideboolEvaluate(AIBehaviorsfsm)
    {
    if(apmanager.hasLowAP=true){
    returntrue;
    }
    returntrue;

    }


    publicoverridestringDefaultDisplayName()
    {
    return"Skeleton";
    }


    #ifUNITY_EDITOR
    /*
    //ImplementyourowncustomGUIhereifyouwant to
    publicoverridevoidDrawInspectorProperties(AIBehaviorsfsm,SerializedObjectsObject)
    {
    }
    */
    #endif
    }

    And heres the apmanager script:

    using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using AIBehavior;

    publicclassAPManager:MonoBehaviour{

    publicTexttext;

    publicAnimatoranim;

    publicintmaxactionPoints=50;

    publicboolhasLowAP=false;

    publicboolhasHighAP=true;




    //Usethisfor initialization
    voidStart(){

    }

    //Updateiscalledonceper frame
    voidUpdate(){
    text.text=maxactionPoints.ToString();
    if(maxactionPoints<15){
    hasLowAP=true;
    }elseif(maxactionPoints>15){
    hasLowAP=false;
    }

    if(maxactionPoints>40){
    hasHighAP=true;
    }elseif(maxactionPoints<15){
    hasHighAP=false;
    }
    }

    publicvoidhasMoved(){
    maxactionPoints=maxactionPoints-2;
    }

    publicvoidhasFired(){
    maxactionPoints=maxactionPoints-10;
    }

    }

    Any help would be much appreciated. Thanks.
     
  15. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    It looks like your "apmanager" variable isn't getting assigned properly. It's likely because the APManager is a component of the AI object whereas the Triggers are components of an object directly under the AI's root.

    So instead of:
    Code (csharp):
    1. apmanager=GetComponent<APManager>();
    Try:
    Code (csharp):
    1. apmanager=transform.parent.GetComponent<APManager>();
    See if that solves the problem. :)
     
  16. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    I wrote 2 basic ones just to get started learning how to write new actions.
    https://www.dropbox.com/s/rp6806nqtedw7y2/PlayMakerActions.zip?dl=0

    Let me know how these work for you so far :) Also, can you send me your wishlist of actions you'd like to have that would be related to AI Behavior? I don't use Play Maker, so it would be nice to know what your needs are as a user.

    Thanks!
     
  17. maxmarkmorphious

    maxmarkmorphious

    Joined:
    Nov 6, 2015
    Posts:
    6
    Thanks buddy. That did it alright. My soldiers states now successfully go to 'unitturnfinished' when the ap goes down and changes back to state idle when the ap points are reimbursed. I've been working on this for days and almost have it working right thanks to you.

    Unfortunately, I have another problem. When the ai gets to it's next turn (turn 4) and the process starts again he goes through all the states alright but nothing actually happens as he goes through them. This results in him getting stuck on the 'unitturnfinished' state because he doesn't have enough low enough ap to be able to go back to the original idle state.
    (the ap is being taken when he fires the bullet on his onAttack function but the onAttack function is never called the second time around).

    This is true even within one round of states. For example if I set him to go to 'attackstate1' and then from that state call 'attackstate1' again with a timer trigger of 2 seconds he starts the attack state again but doesn't do anything? The states don't want to seem to be called more than once whether they are cycling through all the states in a loop or even if one state is being called again from the same state. Any idea's.

    Edit: So I tried moving my soldiers away from the enemy soldiers on turn 3 just to check if the seek was working second loop around and it does. Only the attack states aren't working second time around. Seems I can't call any of the attack states more than once? What have I done wrong?
     
    Last edited: May 17, 2016
  18. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Okay, I have a pretty complete list of basic actions now. It's in the same zip file on Dropbox:
    https://www.dropbox.com/s/rp6806nqtedw7y2/PlayMakerActions.zip?dl=0

    I'm pretty confident in writing these actions now, so please let me know if you hit any road blocks of things you need and I'll try and get them implemented for you. It may be better to email them to me nathanwarden@icloud.com

    Anybody else reading this who uses Play Maker, please feel free to email me with your needs as well :)

    This will be pretty difficult to diagnose from here. The attack state shouldn't have any limit on it by default. Is it possible you can send me a reproduceable project with the issue via Dropbox, Google Drive, or whatever you prefer? nathanwarden@icloud.com
     
  19. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Hi @NathanWarden , I have just discovered this fantastic asset and I have one question about it. Is it possible to trigger different animations from within the same state? For example, for the Melee state, if I had one attack animation for if the enemy is 1m away and a second animation for if the enemy was 2m away. Is it possible to do this within the Melee state? Or would I need to create a new state for each animation?
     
  20. maxmarkmorphious

    maxmarkmorphious

    Joined:
    Nov 6, 2015
    Posts:
    6
    So I sent the issue to your e-mail address provided using google drive but I notice that your e-mail isn't a google e-mail. Is this going to be a problem. The file is 106MB
     
  21. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    Hi I recently(August 2016) bought AI Behaviours. I like it, yet i haven't used it because all the Tutorial videos are for the old system and the new system has changes. It feels those tutorials were made in 2012 or something when AI Behaviors just came out.

    Moreover the documentation is the same, for the old system.

    And i have other other questions how do you even get your animations into the AI behaviors system?

    And other questions
    First, for the Attacks, defends etc, you can only have one animation. Can it be possible to have multiple? If an enemy is a fighter he needs to kick, punch, hook, uppercut, etc not just do one animation. Is it possible through Mecanim? How? There's no explanations or tutorials on it.

    Secondly, how would you apply the same behavior to multiple different enemies? Or do you mean we have to do the whole setup for each individual enemy? Again, there's no mention of these at all. All the video tutorials work with one enemy at a time.
     
  22. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Thanks for your purchase. Yes, there have been many changes since that documentation was put up. I've been trying to figure out a way to make it built into Unity itself and would like to make that possible for when I release 2.0.

    These are using two components. The first is the AIAnimationStates component. The second is adding either the "CharacterAnimator" or "MecanimAnimation" component. CharacterAnimator is for if you're using the legacy animation system and MecanimAnimation is obviously for if you want to use Mecanim. The animations need to be named properly in the AIAnimationStates in order to be used correctly. If using legacy the names are just the clip names. If using Mecanim they need to be in the form of "Layer Name.State Name".

    Most of the scene examples use Legacy animation, but we also have a few with Mecanim (just do a search for Mecanim in the Project window).

    These only use a single animation on purpose. You'll want to setup each state for each attack type. The attack state has an attack point on it, so it's not practical to setup multiple clips since each have different attack points. Also, each attack will have a different attack damage, and a different attack sound, etc... I may change this in 2.0 though. I will write it down on my list of ideas to change for 2.0 since making this change would break everybody's attack states if they upgrade. 2.0 is the place to do that. :)

    This is something I want to simplify for 2.0, but for now you need to make a prefab of the AI itself, then you can put the "graphical" portion (the animated character, for instance) for the enemy under that. Obviously this means that each enemy will share the exact same AI. For 2.0, I want to modularize this so you can use groups of behaviors for each enemy instead of the whole stack.
     
  23. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    @NathanWarden are there still plans to update this asset? It has been almost a year now since any changes were made :(
     
  24. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Hamesh, thanks for asking as this has been on my mind lately. It's looking like one of my good friends will be taking over the project. I just don't have time to maintain it anymore but don't want to leave anybody with an unsupported asset either, so I think this will work out best for all of us. :)

    I'll more than likely make an official announcement tomorrow.
     
    Hamesh81 likes this.
  25. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    That sounds like a great plan Nathan. I don't like to whinge but it's just that when I originally purchased the asset it had already been many months old and the changes in Unity had made several of the example scenes broken, which we discussed then via email. The existing features are excellent and there is no need for more, perhaps just an update to bring everything in line with the current version of Unity. Looking forward to this :)
     
    Last edited: Nov 9, 2016
  26. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Daniel has agreed to taking over the project. More news coming soon! :)
     
  27. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    Hello everybody, I'm Daniel and I'm going to be the one who will take care of the issues or suggestions to keep improving this AI system.

    I'll be updating the documentation to avoid confusion or problems in setting up the AI.

    If you have some issues, questions or suggestions just let me know.

    In the meantime here are the release notes for the latest update which should be live on the asset store soon:

    =====================================================
    Version 1.11
    =====================================================


    Features:
    ------------

    Added PlayMaker actions.
    Added a Path Status trigger. Now you can detect if a NavMeshAgent based AI can make it to its' destination.
    Added an option to the seek state to navigate as close to the target as possible.
    Added a "No Movement" transition to the seek state.
    Added an attack mode based on a time interval instead of based on an animation.
    Added a debug message as to why the agent can't rotate toward a target.
    Added the ability to turn off debug messages.
    Added a pathing script for Mecanim using the Astar Pathfinding project.
    Added a "returnToPreviousState" option to the GotHit state, which ignores the GotHit animation.
    Added the possiblity to spawn items when entering a state.
    Added some new options to the DeadState
    - You can change the tag of the AI
    - You can destroy the colliders
    - You can destroy components
    Added a label that displays the "Attack point" time.


    Changes:
    ------------

    The AttackState now has a default option to only find visible targets or not
    The AttackState will now automatically switch to "Always Animate" and back to the defaultvalue
    Refactored the main AIBehaviors component to be slightly faster when getting sight position or direction under certain circumstances.
    Refactored the main AIBehaviors component to be safer when getting a state by index.
    Moved menu items under the Tools menu.
    Hit_By_UFPS is now blocked by a compiler define instead of using a zip file.
    UFPS, Astar, and PlayMaker integration now all uses defines controlled via a smcs.rsp file.
    The FleeState now uses the enumeration "AwayFromNearestTaggedObject" instead of "AwayFromNearestPlayer". The functionality is the same, but the name is clearer.


    Fixes:
    ------------

    Fixed a bug where the AI attack method wouldn't register if the attack point slider was set near 1
    Items with the HideInInspector attribute will also be hidden in the AI Behaviors inspector.
    Fixed a possible array out of bounds exception in the Seek state.
    The Astar-AIBehavior character controller scripts now destroy the seek target when the AI is destroyed.
    The seek target now gets reset when the Seek state ends.
    Fixed a bug with the Attack state not rotating toward the attack target properly.
    Fixed a bug in the Audio trigger that was caused by Unity handling audio playback differently than before.
    Cleaned up the Seek State scene example a bit so the AI acts the way a user would more likely expect it to.
     
    Hamesh81 and gurayg like this.
  28. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Thank you so much for those updates @dpy :)

    After updating the project I have some questions about the following two issues:

    1) Flee state
    In the flee state demo, the "start flee distance" variable appears to be ignored since setting it to any number does not appear to change the AI's fleeing. The AI begins their flee irrespective of what this is set to. Also I have noticed in the inspector, "AwayFromNearestPlayer" is still showing, and when setting the "flee mode" to this the "start flee distance" and "distance to target threshold" do not appear to have any effect. When setting the "direction seek distance", a value of 1 has the AI moving backwards (facing player) while moving away; but setting a value of -1 has the AI moving towards the player as if they were seeking. Shouldn't a value of -1 have the AI facing away from the player but continue to move away from them still?

    2) Audio trigger
    After testing the demo scene I am still unsure exactly how this trigger is intended to work. At runtime, moving either of the audio source gameobjects near either AI does not appear to do anything as the AI's continue to idle. I would imagine that an AI would "listen" for specific sounds within a certain range, eg. the player's running footstep sounds when within 5m of the AI would trigger the AI's seek state, but stealth walk footsteps would only trigger a seek within 1m of the AI.

    Please let me know your thoughts on the above as I want to make sure it is not a project update issue at my end. I have deleted and reimported the asset several times but the above issues are still happening.

    Look forward to your reply.
     
  29. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    Hi Hamesh81, you're welcome ;)

    I'm going to rewrite some things on the FleeState to make it more clear and work better. I will include it in the next update. If you really need it I can send it to you when I have it done.

    About the issue with specifying the direction, the number you put there is the direction the AI will move, no matter where the player is.


    The AudioTrigger checks if the AI "heard" a sound from a GameObject with the specified tag. You'll need to figure out the "Volume Trigger Level" according to the distance you want him to hear. The "Audio Cache Point" specifies when the AudioSources on the scene are scanned. The "Set Audio Transform As Seek Target" option is to pick the AudioSource GameObject and set it as the target of a specific SeekState (in this case you should pick that SeekState to be switched to, when triggered).

    Regarding your issue, you have to check the "loop" checkbox in the AudioSource if you want to keep playing the sound so the AI will follow it when you move it in runtime.
     
  30. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    It seems that I misunderstood the purpose of the flee state, it makes sense now that you explained it. I was looking for functionality similar to an evade like state, where the AI would maintain a specific distance away from the player and try to avoid the player. But this is definitely more appropriate for an evade state and not flee. Make sense now :)

    For the audio trigger, I'm still having trouble visualizing how this works exactly in a practical sense but I'll play around with the demo scene until it clicks. When the documentation/tutorials are being updated if this could please be explained so that the practical uses are clearer. Thanks dpy
     
  31. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    About keeping a distance from the player maybe you could use the FleeState with BeyondDistance and WithinDistance triggers, so that if the AI is between the 2 values he will flee.

    For the audio trigger try this:
    - In the demo scene select the "Audio with linear falloff" and check the "loop" option in the AudioSource
    - Select the AI named "This AI reacts to the audio with Linear Falloff" and set in the AudioTrigger the "Volume Trigger Level" to 0.3
    - Play the scene
    You will see that the AI is not "hearing" the sound.
    - Now change the value to 0.1
    You will see now the AI "hearing" the sound and going to the source.

    The "Volume Trigger Level" is something like the hearing sensitivity of the AI (smaler value is hearing further)
     
    Last edited: Nov 25, 2016
  32. maxmarkmorphious

    maxmarkmorphious

    Joined:
    Nov 6, 2015
    Posts:
    6
    I'm having real problems implementing the A* pathfinding project with ai behaviours. With respect, the tutorials on this topic aren't very good. Nathan/Daniel could you provide some info or code on how to have some basic interactivity between the two systems? Getting the ai to use the A* pathfinding system to move during the seek state would be a good start. Thanks.
     
  33. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Thanks for that @dpy . I will try this and post back if I have any issues :)
     
  34. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    Hi maxmarkmorphious, I have been testing the basic things you need to use AIBehavior with A* and actually its quite easy to make them work.
    - Add a plane to your scene, add an empty GameObject with the "AstarPath" script, add a GridGraph in this script, add you "enemy" to the scene with the AIBehavior and set a withinDistanceTrigger to go to seekState, set Player as seekTarget and finally add to the enemy the "AstarCharacterController" script (this will automatically add also the "AIPath" and "Seeker" scripts and the regular "Character Controller").
    That should be enough for the AI to follow you. I have tested it myself step by step.
    Let me know if you still have issues ;)
     
  35. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    Today we uploaded a new update, it should be live on the asset store soon.
    It includes a new manual that explains in detail how to set up AI Behavior and each of the states and triggers.
    This are the release notes for the new version:

    =====================================================
    Version 1.12
    =====================================================

    Features:
    ------------
    Added new documentation manual "AIBehaviorManual.pdf".
    Added a "Settransformasseektarget" option to the SpeedExceededTrigger.
    Added a "PlusOrMinusDamage"value to the AttackState,doadd some randomness to the damage.
    Added a "hitStateDuration"value and "changeToState" option to the GotHitState, to specify how long the hit state lasts and what to do after it.
    Added a "HelpCondition" to the HelpState, to choose in witch cases the AI will help another AI asking for help.
    Added a "ReturnToPreviousState" option to the OffMeshLinkState.
    Added a GetInvisibleState.
    Added an "totalAmount"value and "exactPosition" option to the ItemSpawning on BaseState.

    Changes:
    ------------
    Removed the "Seekitemswithtag" option on the SeekState, it uses now the tags as all other states.
    Removed "Speedobjectstag" and "Seekobjectstag"from the SpeedExceededTrigger, it uses now the tags as all other triggers.
    Removed "Seekobjectduration"valuefrom the SpeedExceededTrigger.
    Removed "Startfleedistance"from FleeState,this should be setas a WithinDistanceTrigger in a previous state (like Idle).
    Renamed "Directionseekdistance" to "Stopfleedistance"in the FleeState.
    Modified the "05_state_seek" scene, now the enemy seeks and collects all the boxes of the scene.
    Improved "08_state_ranged_attack" scene, the enemy now rotates toward the target.
    Improved the "08a_state_ranged_attack_and_move" scene, the AI now rotates toward the player, seeks him if he goes too far and flees if it gets too close
    Improved the "10_state_got_hit" scene, now it shows the got_hit state, defending state and dead state. And how the defending bonus can work.
    Simplified the CooldownableState class, it now only has "Cooldowntime" and "Startcooldownonstateend" options.

    Fixes:
    ------------
    Fixed the "03_state_follow" scene, just using a BeyondDistanceTrigger and a SeekState.
    Fixed FleeState condition checking,where it wasn'tstoppingcorrectlyatthespecifieddistance.
    Fixed the "Destroycomponents" option in DeadState, should be able to drag and drop the components.
     
    Hamesh81 likes this.
  36. SoulSpectrum

    SoulSpectrum

    Joined:
    Nov 4, 2016
    Posts:
    5
    Is it possible to have group movement? Such as DOTA 2 or Right Click to Necromance where the AI can move together and not push each other around. This is an amazing looking product but I'm still wondering about some of the features vital in AI I'm looking for. If you can explain how if it is possible I'd greatly appreciate it, thank you.
     
  37. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    Hello SoulSpectrum, it is possible to do what you ask.
    The states are individual for each AI but you could have a script that sets the AIs of a group of "selected" units to a seekState with specific targets for each AI with the desired spacing and formation.

    Edit: We will include an example of it in the next update.
     
    Last edited: Jan 6, 2017
  38. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    A new update is avaiable, version 1.13
    This are the release notes:

    =====================================================
    Version 1.13
    =====================================================
    Features:
    ------------
    Added a WanderState that makes the AI walk arround randomly and a demo scene for it "18_state_wander".
    Added a StepBackState that makes the AI keep a distance from the player/target and a demo scene fo it "19_state_stepback".
    Added a "Duration" and a "ChangeToState" options to the GetHelpState.
    Added a debug label to the HelpState to know how far it is from the target point.
    Added a group/formation moving example script with an example scene.
    Added an AITransform parameter to the AIBehaviors script.

    Changes:
    ------------
    Updated project to Unity 5.5
    Each state can have more than one Audio, in those cases it will pick one randomly.
    Removed the "Advanced Mode" option in the AIBehaviors script, now it always shows all the advanced options.

    Fixes:
    ------------
    Fixed the "HasMovement" checking in the SeekState, now it only checks it each second.
    Fixed the "MultiplePlayerAttackPoints" demo scene that was sometimes shooting more than one projectile.
    Fixed AttackState to wait until the animation is finished before to go to the ReloadState in last attack before reload
     
    Hamesh81 likes this.
  39. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    Hello i recently got the newest version of AI BEhaviors. version 1.13.
    I've never managed to learn how to use AI Behaviors because the system has changed and the documentation and videos are still from 2012.

    There is a menu AI Beheavior with Mecanim setup, Legacy setup, etc. I chose mecanim setup.
    But when i try to add the Animator it won't accept it. The field only seems to accept gameobjects. I'm on Unity 5.4 by the way.

    Also where you Edit the states and add animations, when you add all it says is "Untitled". you can't really add an actual animation.

    besides these issues...the main problem is that the documentation says one thing but the new system is different.
    Can i get some help? thanks
     
  40. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    I'm having trouble with the various things. Now i understand how to get the mecanim states/animations to show up instead of saying "Untitled" But none of the triggers does anything.

    for example i followed the video tutorial example where after few seconds the player is changed to dead.
    In my case starting from idle animation i put change to attack after 3 seconds but it doesn't change at all.

    I also want to know if it's possible to choose amongst different animations for the Attack state? 1 animation is not enough. specially in a fighting game
     
  41. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    Hello greatUnityGamer,

    Did you took a look to the AI Behavior Manual in the Documentation folder? there are quite details of each state and trigger and also how to set up an AI (It was updated last month).

    About the questions you ask, In the example you're talking about a TimerTrigger is used. This will change to the specified state after the indicated time. Probably the problem is with your attackState you're trying to change into, Is there a "target" to attack? If not it will change into the "No target state" (in the attack properties). The attackState need a target to attack. For testing maybe just put a box there with the "Player" tag or whatever tag the AttackState is using.

    For having different attack animations, the best whould be to have different attackStates each with a different animation, so you can have different attackPoints, damages, etc. If you want the AI to go randomly to one of them use the "randomStateTrigger" nested to whatever condition you want to give to it (WithinDistance for example is the more common).

    Let me know if that helped you and if you have more questions.
     
  42. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    Hello dpy. THe documentation folder only has 2 txt files. Readme and ReleaseNotes.
    Then in the main AIBehavior folder there is the AI Behavior Made Easy Basics.pdf and the AI Behavior Made Easy Docs.pdf which are short PDFs and do not explain in depth how to setup the AI. Those last 2 still say 2012
     
  43. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    Ok, its probably that you're not getting the latest version. Here is the new manual:
     

    Attached Files:

  44. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    dpy, but i went Open in Unity and then there was a button saying update I pushed that and i thought i got the latest version. If i'm not getting the latest version that way, how am i supposed to get it?


    Edit. by the way now I understand how to use the WithinDistance trigger and it works. But i'm having a problem . After i'm within distance enemy starts punching me but , how do i return the state to idle after he punches once? Do i use what Trigger ?
    Because it only punches once and then it goes to Idle animation and never again punches. which means AI Behavior still is in Attack mode probably. or something. just not performing the atack animations anymore.

    I don't know if i'm doing it right, in Mecanim I got my Attack animation/state with an arrow going to the Idle state.


    PS I use MecanimAttack for the attack state in AI Behavior
     
    Last edited: Jan 31, 2017
  45. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    Hello I think i'm not getting the most current version of AI Behaviours. In the Release notes at the top it says Version 1.10. What can i do to get the latest? I pushed "Open in Unity" and then UPdate and this is the version I get(1.10).
     
  46. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    greatUnityGamer, the latest version was updated to Unity 5.5 if you update Unity you'll get the latest version. Unity stores different versions of the packages according to the different Unity versions they were updated and when someone downloads an asset it will give him the version according to the Unity version he has for avoiding errors.

    About your issue with the mecanimAttack state, maybe check while in Playmode in wich state the ai is staying (the green one in the inspector) if he is in attack state but not playing the animation maybe your animation is not "looping":
    - check your animation clip and check "loop time", "loop pose", and all the bake "into pose" options.
    - Remove transitions (arrows) in the animator, as you want the AI to handle the transitions between animations.
    - For going back to idle after a number of attacks set the "reloadState" and "Attacks before reload" or you can use a "beyondDistanceTrigger" so that when you are far enough the ai will stop attacking you.
     
  47. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    Thank you dpy for that.
    Now i'm having a problem when i set my enemy to Rotate to face the player, it in fact does in idle state because the option to ROtate to face the player is only exist in the idle state. But when it atttacks me i can sneak behind him or something and he keeps attacking and rotating different directions . weird

    I also want to ask about Randomization. Is there a way to have the enemy attack at different unexpected times using some Random timing? SO far when i've set it to attack WithinADistance or whatever it attacks repeatedly at the same rate with same wait between attacking.
    This is in version 1.10 as that is the version I have.
    I will try to update Unity to 5.5.
     
  48. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    dpy, here's my scenario now. I"m using in my Idle state a trigger "WithinDistanceTrigger" Which changes to the attack state. ANd it works only once. It throws a punch and then it stays in Attack state and it freezes at the last frame of the punch animation. Like you said, i removed any transitions from the Animator. SO what's going on? Why doesn't it go back to idle.


    Should there be some kind of trigger i use in the Attack state, to make it go back to Idle once the punch animation is ended?
    ****************************
    aNOTHER method i use is to Use the Within distance in the Idle state and use the TimeTrigger in the attack state. that seems to work but what's happening is when i manage to go behind the character he no longer goes back to the Idle state. and thus he stays frozen and does not face my character( I have Idle set to Rotate towards character). I don't know why he gets stuck in the attack state. BUT ONE INTERESTING THING IS. If I manage to get behind him he gets stuck in attack state right, but if i move to face his front of his body he goes back to Idle state and it works fine again.

    PS Now updated to Unity 5.5 and grabbed the latest AI Behaviour
     
    Last edited: Jan 31, 2017
  49. dpy

    dpy

    Joined:
    Nov 14, 2016
    Posts:
    22
    greatUnityGamer, maybe take a look to the "07_state_melee_attack" demo scene, and see how it's set up, it should be almost the same for mecanim.

    Sometimes it helps for example to put 0 "attacks before reload" and having the AI going to Idle before each attack so it will rotate towards the player each time. Maybe also check that the "Find visible targets" option from the AttackState is unchecked. Also make sure that in the "AI Animation States" script all the animations have "cross fade in" and "cross fade out" checked, thats what makes the transitions between animations.

    For the random time you can nest a timer trigger in your "withinDistance" trigger set it to 0 and add a "plusMinusDuration".

    If you still are having issues maybe you can upload it to Dropbox or something like that and send me the link so I can take a look.
     
    Last edited: Jan 31, 2017
  50. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    Thanks for your help. Sorry that this is confusing to me. but i'm trying my best.
    Thanks for the advice.
    I would also like to know when you set up your environment to have a Navmesh, will the enemies be ready to walk on it? Or do i need to add something else to them? Do they need rigidbodies or something?
    I tried setting them up in a Navmesh environment and they kept attacking me(punches) moving towards me and going half way through the wall. So they did not obey the navmesh.

    I will try to watch the tutorial videos again more carefully.

    *******
    I have one question also. Can you save the enemies with AI Beahaviour as a prefab so that you can instantiate a bunch of enemies at runtime?