Search Unity

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

[Released] Advanced AI Pro - AAA AI Solution -

Discussion in 'Assets and Asset Store' started by Zozo2099, Feb 3, 2013.

  1. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello

    I updated the UFPS Guide for v1.5.0 and now the code line to replace in number 166
    Please refer to the guide again

    Cheers
     
  2. JesterMaster

    JesterMaster

    Joined:
    Oct 29, 2014
    Posts:
    34
    Hi

    I have Ai guard that shoots zombies. Problem is that it keeps shootin geven there is no more zombies left. How can I make it stop.
     
  3. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    I just purchased the asset, and imported it into my scene in Unity 4.6.4f1, and get the following error which is preventing the scene from running :
    "Assets/Advanced AI/Scripts/PlayerHealth.cs(22,44): error CS0122: `CharacterMotor.canControl' is inaccessible due to its protection level"
    How to fix it please. Thanks.

    Edit: I have deleted the scripts in the showcase folder for now, and now I can run the scene, however, I'm getting this error when being attacked:
    IndexOutOfRangeException: Array index is out of range.
    AdvancedAiEnemy+<MeleeDelay>c__Iterator15.MoveNext () (at Assets/Advanced AI/Scripts/AdvancedAiEnemy.cs:1966) - when I'm standing still and being attacked (melee) by the AI. This has come up earlier (halfway down page 2 in this forum, I think, some else brought it up way back then).
    I'm also having trouble getting damage to register when I get hit by the AI (I'm using Realistic FPS, and followed your setup notes, and it seems to be working); the AI damages me maybe once every 6 or 7 attacks. I tried varying the arrival distance, both closer and further away, but it doesn't change. It's when I was standing still and let the AI attack me to see how often it damaged me that the error above came up in the console. Thanks again, and please note that I am very impressed with your asset, it is definitely a step above anything else on the Asset Store as far as I am concerned.

    Cheers.
     
    Last edited: Jun 13, 2015
  4. Zaddo67

    Zaddo67

    Joined:
    Aug 14, 2012
    Posts:
    489
    I don't own this asset, but your inaccessible problem is a coding mistake I make occasionally. To fix it, you need to make the method public. i.e. Open up PlayerHealth.cs script, find the canControl method, if it has private, delete this first, then put public in front of it. eg: public canControl()
     
  5. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    Ah, thanks very much for the tip :)

    Edit: It didn't help because it's set up differently. This is the troublemaker:

    private void Update()
    {
    if (health <= 0)
    {
    // Manage your player's death logic here
    // A small example here, you note that I changed the layer of the target so the AI will ingnore it when it is dead.
    health = 0;
    gameObject.layer = 9;
    GetComponent<CharacterMotor>().canControl = false;
    }
    }
     
    Last edited: Jun 14, 2015
  6. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    517
    hi I'm a new unity user and I'm making an fps survival action puzzle game (LOL) i bought realistic fps prefab and I want to know if Advance Ai pro run well with it and is ai behavior are realsiitc and naturals..i'm using s-inventory and unity dialog system too..
     
  7. SkermunkelStudios

    SkermunkelStudios

    Joined:
    Dec 29, 2012
    Posts:
    156
    Hi Zozo, Im sitting with the last 2 problems in my AI at the moment, Ive gotten most of everything to work but these 2 things are still giving me some hassle:

    1. I cant get my Advanced AI Enemies to jump up, they jump down just fine and there are plenty of off mesh nav links that go up, but non of the AI want to jump up.

    2. For some reason all my Advance AI Enemies always try to stop underneath the player not at the arrival distance, no matter how high I set the arrival distance (someitmes it works when I just stop and wait for the enemy to come to me but if I keep running it always tries to stop underneath the player).

    I am running Unity 5.1.1 on Windows 7 64 bit and I am running the latest version of Advanced AI Pro (v7.0b) without any Custom changes or modifications of my own.

    Please get back to me asap as it is extremely urgent I need to get my AI polished within the next day or two and these are the only 2 things standing in my way. Any advice or help would be immensely appreciated. Thanks in advance.

    UPDATE: Ok Ive managed to figure out how to fix number 1. For some reason auto-generated off mesh links only do jump distance not jump height, so if you want to make youre ai jump up you have to set up some manual off mesh links, this is quite annoying as there are a ton of places to set up and it doesnt make sense why unity only uses distance for the auto generated ones, but at least I know how to fix it now.

    Now I just need to figure out how to fix number 2.
     
    Last edited: Jun 22, 2015
  8. SkermunkelStudios

    SkermunkelStudios

    Joined:
    Dec 29, 2012
    Posts:
    156
    Youre AI and customer service is BAD and you should feel BAD, seriously Ive been left to figure out everything and fix everything myself, with little to no help from this author. The AI is so extremely buggy, at one moment it fumbles around while the next its clayrevoyant and can see throughh walls, most wasted potential in a Unity plugin evar!

    I dont mean to say this in order to be nasty, but as a means of warning other people from buying this waste of money and to hopefully help the author realise his mistakes and fix them, because as is, this plugin is nothing short of pathetic.
     
    Last edited: Jun 27, 2015
    Pandur1982 likes this.
  9. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello

    Yes Advanced AI Pro is completely compatible with Realistic FPS Prefab, you can find the setup guide here:

    http://forum.unity3d.com/threads/released-advanced-ai-pro-aaa-ai-solution.168870/page-8#post-1606612

    If you have any other questions feel free to ask here :)

    Cheers
     
  10. Raynolds

    Raynolds

    Joined:
    Jul 4, 2015
    Posts:
    8
    Hello Zozo2099,

    I have UFPS 1.4.8 and I got confused with your instruction , because I cannot find OnColisionEnter on line 369. Can you tell me where exactly I should put your code .
    I have spent many hours trying to solve this , but unfortunately I'm not a programmer.

    Cheers..

    ps.

    Here I got an screenshot .
    screenshot2.jpg
     
  11. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello

    Maybe that is because you are using an old version of UFPS, so the code lines have not the same number. What you need to do is to search the script file for "OnCollisionEnter" using the search button in MonoDevelop, and then you put the whole method's code between the "if" statement as in the guide.

    Tell me if you succeed to do that

    Cheers
     
  12. Raynolds

    Raynolds

    Joined:
    Jul 4, 2015
    Posts:
    8
    Just to let you know - everything is OK now .

    Thank you very much for the prompt reply.
     
  13. SolusGod

    SolusGod

    Joined:
    Jun 25, 2015
    Posts:
    5
    can you please show me how can i use Victor.Distance Instead of triggers the code is a lot to go through and change by myself,also triggers use a lot of memory.
     
  14. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    @Zozo2099

    I purchased your asset when it was on sale. I am just now looking at it and I am severly disappointed that it works with legacy animations and not mechanim. What bothers me even more is that I have read through this thread and posters have asked you point blank if you are going to switch to mechanim and you didn't reply to a single post. You ignored them all.

    So, I will ask you once again. Are you moving AAI to support mechanim?
     
  15. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello

    Mecanim version is under development :) Support by buying the asset is heavily appreciated though.

    Cheers
     
    daisySa and Tinjaw like this.
  16. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    Thank you very much for answering my question. I now feel it is worth investing my time to learn how to use your asset knowing it has a future. I was worried before, I feel much better now.
     
    julianr likes this.
  17. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    yep, we're still using it. This asset has lots of potential with a renewed life of updates I am sure that the sales and support will follow. Mecanim addition (supporting legacy) will be a plus, must have feature. One side that I feel needs improving more is the shooting; it needs more of a weapon system, where the projectile comes from the weapon.
     
    Zozo2099 likes this.
  18. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    190
    If you can a write a little code, it's not hard to extend his scripts and use it your way. I wrote an extended code based on this script to use Mecanim, it wasn't that hard. I didn't add a support to plugin, don't misunderstand :D

    I just named my boolean variables for Mecanim states into same name of animations, and when an animation blend occurs in the plugin, I just send an event to my extended code to switch mecanim states. Plugin updates become a pain in the ass though.

    Still, I don't know how to add it to plugin itself.
     
  19. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Hi Zozo.. I have an issue, which I'm trying to figure out... I have a gun turret that fires a projectile at the player, when the player is near a zombie AI, that projectile impacts the boundry of the Go Idle radius like it was a force field and the projectile doesn't reach the player.. how can I get through that? I'm using a physics raycast.
     
    Last edited: Aug 15, 2015
  20. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    190
    You either put the Go Idle sphere's object into another layer and set it so projectile won't collide with that layer, or uncheck the button raycast hit trigger.
     
    julianr likes this.
  21. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Thanks. I'll give that a go... I'm experimenting with layerFilters, but not much luck with that atm.
     
  22. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    Does anybody know how to make an enemy ai spawn with the target set? I have no problems with the ai if the enemies are already in the scene, because I can obviously set the target in the inspector, but how do I set the player as the target if I want to spawn them at runtime.
    My scripting ability is limited to JS, so I'm not keen to play around with his scripts. Thanks for any/all replies.
     
  23. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello
    In the script of your turret projectile you need to exclude the Go Idle sphere collision by adding a condition like this:

    Code (CSharp):
    1.    void OnCollisionEnter (Collision collision)
    2. {
    3.  
    4. if (!collision.collider.isTrigger)
    5. //your turret projectile code here
    6.  
    7. }
    If you have difficulties, please paste your code here and I will figure it out for you :)

    Cheers
     
    julianr likes this.
  24. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello

    It is simple, you just need to tag your target as "Player".

    Cheers
     
  25. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    Cheers Zozo. I managed to do it using the following...

    Code (csharp):
    1.  
    2. At the top..
    3. I defined the variables..
    4.  
    5. then..
    6.  
    7. if ( Physics.Raycast(transform.position, GetComponent<Rigidbody>().velocity, out hit, GetComponent<Rigidbody>().velocity.magnitude * Time.fixedDeltaTime, (1 << LayerMask.NameToLayer("LocalPlayer") | 1 << LayerMask.NameToLayer("Zombies") | 1 << LayerMask.NameToLayer("Default")) )) {
    8.            
    9.             if ( hit.collider.gameObject.layer == Playerhit)
    10.             {
    11.            // damage code here
    12.             }
    13.  
    So I get hit detection for the player, zombies, and everything else to produce the desired effects.
     
  26. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    Sorry, I worded my question badly, I mean how do I spawn an enemy ai with the player set as the target in the Target field? My enemy prefab has the player layer etc all set up, but Unity won't let me drag n drop the player into the Target field in a prefab, it has to be done some other way. Everything works fine if the enemy ai is already in the scene, because I can assign the player to the Target field as normal.

    Spawning the enemy without the player set in the target field results in no response from the ai. Using 4.6 Pro.
    Thanks.
     
  27. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    @wheelbarrow - when you drag your AI from the hierarchy to a folder in your project, does it retain your player target? If not, you could always disable the AI in your hierarchy and spawn a duplicate?

    Just tested.. drag and drop AI from hierarchy into a folder, retains the targets and everything else. Can be drag and dropped back into hierarchy or you can use code to spawn it, or use a pool'ing system with spawning if you have lots of AI (saves on memory). Especially when using 4.6 for large scenes.
     
  28. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    Thanks for that tip Julian, I'll give it a shot and let you know if it worked.
    Cheers.

    Update: Gave it a shot and unfortunately it doesn't work, the target field is empty once the ai is moved from the hierarchy into a project folder. Thanks for the effort though :)
     
    Last edited: Aug 17, 2015
  29. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello

    The solution is very simple, tag your target as "Player" and the AI will recognize it once it is spawned into in the scene :)

    Cheers
     
    julianr likes this.
  30. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,210
    yeah, sorry the target field is dynamic and changes when a new target is located. Zozo is correct, however if you want to create prefabs based on the AI you create that can be pool'ed or spawned in using spawn spheres then you can use the prefab. Tagging your player as "Player" and making sure that the Players layer is set, and that the Main Target is set to the players layer name, should do it.
     
  31. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    @ Zozo, you keep saying that, but as I said earlier, that is incorrect, when I spawn the ai prefab, it does not recognise the player as the target. I set up a trigger to spawn a prefab near the player, and the player can run around it without being recognised. If I shoot the ai, it runs off in a random direction until it gets stuck in a corner. Same result if I spawn it further away from the player. My player toon has a Player tag and is on the Player layer, and the ai main target is Player, but without dragging the target into the Target field, it doesn't work correctly.
    Cheers.
     
  32. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hi

    Please verify that the "Player" tag is set to one gameobject only, and not the childs too. The tag must be on the gameobject which holds the collider on it. If two gameobjects have the same "Player" tag then it will make conflits, so check your target gameobject and be sure that only one gameobject is holding the tag, with the collider on it.
     
  33. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    I just checked my player toon, and the root object that has the collider on it is the only place that has the Player tag, and is on the Player layer, any/all children are untagged and on the default layer.

    The ai I already have in the scene when it starts all work well, with no problems, so I know it's not my player set up, the problem only occurs with a spawned ai, which is the same prefab that the "in-scene" ai uses, just without the Player dropped into the target field.
    Cheers.
     
  34. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    It should work with the tag, no way, I have run a test and it worked as it should be, also other customers spawn their AI in runtime and everything works well with the tag, so there is something wrong in your setup, I already encountered this issue before in my project when AI can not recognize the target, and after a lot of time searching why I discovered that the reason was that the camera rig gameobject had a "Player" tag by default. So search your scene hierarchy and be sure that no other gameobjects other than the target are tagged as "Player".

    Cheers
     
  35. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    I've checked pretty much everything in my scene, and I can't find anything else with the Player tag.

    If there was something else with the Player tag, wouldn't it screw up the ai already in the scene, because they all work perfectly well. But you make a good point, if everyone else can spawn a working enemy ai, what the hell is wrong with my scene? I'm afraid I'm at a loss.

    While I'm here Zozo, I've just tried putting Advanced enemy ai on a robot, and I get this error:
    NullReferenceException: GetRef
    AdvancedAiEnemy.Start () (at Assets/Advanced AI/Scripts/AdvancedAiEnemy.cs:374)

    What does that mean? I copied the settings from another working ai, and then just changed the animations to the robot anims.

    Cheers.
     
  36. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hi

    Check your melee attack animations, you may have set multiple animation slots but not all assigned, so check the size of the melee animations and that all of the melee animations slots are assigned.

    Cheers
     
  37. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello everyone

    Thanks to everyone for reporting your issues, I have submitted a new update, and now it is pending review, so be tuned :)

    Changelog 7.1
    • Added "Main Target Tag" string parameter so that if the main target transform is not assigned (in case of spawning AI at runtime) then you can assign its tag to be used, by default it is set to "Player" tag.
    • Added a menu item to add a Shadow Zone gameobject from within the Advanced AI main menu.
    • The retreat distance is now defined by a minimum and a maximum values.
    • Fixed reported issue when sometimes the target is not being detected by the AI within its detection range, now everything should work as normal.
    Let's hope that the update will be available online very soon.

    Note: I've submitted the update using the new beta of Unity 5.2f2

    Cheers
     
  38. retired

    retired

    Joined:
    Jan 13, 2015
    Posts:
    42
    Hello Zozo,
    Great asset, I got everything setup and running with UFPS. Is is possible to make the exploding crates do damage to the AI, if so how can it be done, thanks!
     
  39. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello everyone

    Update 7.1 is now available on the Asset Store

    Changelog 7.1
    • Added "Main Target Tag" string parameter so that if the main target transform is not assigned (in case of spawning AI at runtime) then you can assign its tag to be used, by default it is set to "Player" tag.
    • Added a menu item to add a Shadow Zone gameobject from within the Advanced AI main menu.
    • The retreat distance is now defined by a minimum and a maximum values.
    • Fixed reported issue when sometimes the target is not being detected by the AI within its detection range, now everything should work as normal.
    Cheers
     
  40. AGaming

    AGaming

    Joined:
    Dec 26, 2013
    Posts:
    100
    Version 7.1a - 7.1 causes a drop in FPS on mobile platforms to 90% Unity 5.2. I revert to an older version.
     
  41. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hi

    This is a Unity 5.2 issue, older versions of Unity have not that issue, I will look into that though, as I know of what it is caused.

    Cheers
     
  42. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello to all

    Version 7.2 is submitted to the Asset Store, waiting to be approved.

    Changelog 7.2

    - Added "Line of Sight Height" parameter, with a visual gizmos of LOS in the editor. See the documentation for more information.

    This is an important feature, now you can visualize the LOS in the editor window, a red line coming from the AI transform point, you can adjust its height to match the eyes of the AI character.

    Previously, the LOS was coded to be casted from the transform point of the AI gameobject which is not accurate sometimes because the transform point can be anywhere in the body, below or in the middle, which leads to errors in the detection of the target. Now it should be realistic :)

    As shown, you can now edit the LOS height in the editor:


    Stay tuned for the release.

    Cheers
     
  43. kurotatsu

    kurotatsu

    Joined:
    May 10, 2012
    Posts:
    588
    How will this affect a player on a roof, above the enemy, in the sphere but in front of them.

    I've been patiently waiting for to implimentation of the vision cone(limited by height) we discussed a looooong time ago.

    It would add one more stealth option for attacking enemies patrolling or wandering that are facing you, but you are above their head on a roof or something waiting to pounce.
     
  44. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hello

    Update 7.2 is now available on the Asset Store.

    Changelog 7.2
    • Added "Line of Sight Height" parameter, with a visual gizmos of LOS in the editor. See the documentation for more information.
    Cheers
     
  45. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Hi

    Please test the new LOS feature and tell me what do you think about!
     
  46. arnesso

    arnesso

    Joined:
    Mar 3, 2015
    Posts:
    96
    I am using Advanced AI pro 6.1 I added my enemy with animation it works quite well, but if I am not enough close the enemy does not move and not plays animations. If I step closer it starts moving and playing animation. Any idea ,what should modify or setup ?
     
  47. kurotatsu

    kurotatsu

    Joined:
    May 10, 2012
    Posts:
    588
    Try increasing the size of your goIdle sphere. This is for preformance why it does that.
     
    arnesso likes this.
  48. kurotatsu

    kurotatsu

    Joined:
    May 10, 2012
    Posts:
    588
    Imported newest update(and reimplimented my mods.;)), and I must say LOS works like a charm.

    Well Done Zozo!


    Edit:

    I wonder if this might be a viable option for the rooftop issue(though I'm not too worried about as much anymore really, just would be another cool option to consider.):

    http://answers.unity3d.com/questions/499013/cubecasting.html

    I'd still like to have a true mecanim option though, rather than the baking anims, if just for the convinience of swapping in anims to the animator a little quicker for the ai to use, you need to make it work with root motion, just the animator and a couple parameters and you'd be set.

    From what I can tell, it wouldn't be too hard, and you could just make a duplicate script for each ai type, and the developers could choos to use both legacy and mecanim characters to their hearts content.

    This is still my FAVORITE ai solution, and I've been buying them all to test. So keep it up Zozo, you are doing a helluva great job.
     
    Last edited: Oct 7, 2015
    julianr likes this.
  49. canaljuegos32

    canaljuegos32

    Joined:
    Jun 29, 2015
    Posts:
    63
    Is the Guide to make Advanced AI Pro compatible with Realistic FPS Prefab updated?, because i cant find half of the stuff.

    Edit: Ok found there is a RFPS prefab but i get this message when i put it in the scene
    NullReferenceException: Object reference not set to an instance of an object:

    AdvancedAiEnemy.Start () (at Assets/Advanced AI/Scripts/AdvancedAiEnemy.cs:406)

    also when i try to put waypoints i get this:

    You have to be in Static_Waypoints mode first!
    UnityEngine.Debug:LogWarning(Object)

    Im still an unity noob.

    Edit2: fixed all, also I had to put (add) this linein position 1102 in RFPS weaponbehavior.cs
    hit.collider.gameObject.SendMessage("GotHit", damage);

    Dint delete any "if" statement and damages seems to work fine.

    Now all seems to work fine except sounds. I only hear the enemy fire sound (sometimes recharge too) and always same volume even if enemy npc is far away. If I put sound volume to 0 in advanced ai script still the same.
     
    Last edited: Oct 17, 2015
  50. Andrey_Kiselev

    Andrey_Kiselev

    Joined:
    Jun 25, 2014
    Posts:
    9
    Hi! Need Your help with this:

    Assets/Advanced AI/Showcase/Scripts/StepsHandlerExample.cs(23,40): error CS1061: Type `CharacterMotor.CharacterMotorMovement' does not contain a definition for `maxForwardSpeed' and no extension method `maxForwardSpeed' of type `CharacterMotor.CharacterMotorMovement' could be found (are you missing a using directive or an assembly reference?)

    I use Unity 5.2.1f1