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

ICode (AI For Mecanim 2.0)

Discussion in 'Assets and Asset Store' started by DevionGames, Dec 18, 2013.

  1. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    Hello Zerano,

    Is there something I have to do to get the Root Motion to work? other than the tick box. When ticked my character just runs forward and stops following anything.

    Also, I'm trying to add 2 transitions going to the same state, 1 with Distance Greater and Distance Less and one with Distance Greater Distance Less and FOV. This doesn't seam to work correctly. Is there a restriction on doing this?

    Cheers!
     
    Last edited: Mar 6, 2014
  2. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624

    Yes, you need to handle the rotation by yourself/actions using GetAngleVelocity in the latest version. In the next version it will be called GetAngularVelocity.
    The Apply Root Motion tick box only stops the rotation on the NavMeshAgent, applies the rotation from the animator and updates the velocity of the NavMeshAgent from root motion deltaPosition. I am very sorry that the tutorials are coming so slow, i only do this as a hobby in my free time, so i am not realy that fast as others.

    Could you tell me what FOV is?
     
  3. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    Ahh thanks that makes sense :) and thankyou for the great asset by the way, its saving me allot of time and I'm getting my head around the way things work now I think!

    FOV = Field Of View

    I'm trying to make an AI that can see a Longer Distance with a FOV but will react no matter where its looking if you get to close. I've added Two distances to each transition one transition set to kick off closer than the other. I then add a FOV to the longer distance one. It doesn't seem to work though. I'll keep fiddling ;)
     
  4. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    There are no restrictions for this.

    I know that this asset is going to be more complicated as i first thought. In the next version you can recreate all states with actions, but i want still keep the pre defined states so you have less settings todo if you just want to create fast an ai, otherwise i would recommend to use actions where you can do the most customization.
     
  5. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    Zerano,

    I have upgraded from version 1.2 to 1.3.1 Now I am getting the following error.

    "The type or namespace name `CustomCondition' could not be found. Are you missing a using directive or an assembly" in my playerHealthCondition.cs script.

    Also do I have to re-write the AI Controller. It seems pretty messed up when I tried to open the AI Controller. All my conditions look empty.

    Thanks
     
  6. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Hello, yes i am very sorry, custom conditions are handled in the same way now as the regular conditions. You would need to derive from BaseCondition.
     
  7. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    Zerano,

    I am started to write my AI Controller again. Do you think 1.3.1 is stable enough to begin or there is some major release coming that will break the controller. It will be nice to have away to upgrade it without having to re-write from scratch. I had it working :( since I wanted to use the latest version which looks to have more features and much more streamlined. Wish me luck.

    Thanks
     
  8. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    I renamed a few things for the next version, so you would need to update some actions by hand, but there will be no such a big jump like it was from 1.2 to 1.3. Most of the things that will be new in 1.3.2 are more actions and some optimized states.
     
  9. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    365
    I've got a problem: My AIControllers have no properties
    To recreate the problem I do the following steps
    1. Create a new empty project (with no assets)
    2. Open the window to the asset store and import the AI For Mechaninim v1.3.1 Beta
    3. Double click Install Examples.

    When they've installed
    4. Create a plane
    5. Drag the Ratkin model in
    6. Right click in the Project Window and select create AIController
    *Note it always creates it in the Assets folder (not the sub folder I have highlighted)


    The AIController has no properties
    and when I double click to open it I get the right side with the State but no left hand side with the properties.
    I've created a little video to show whats happening



    Also when I add the AI Runtime Controller it doesn't automatically add the Nav Mesh Agent

    I am unable to do anything without the properties and dont know what to do

    Roy

    ------------------------- some time later ---------------
    Update:

    I opened an old project where I had used Mechanim AI in the past and the properties on the AIController were fine ??
    So I Right clicked in Project
    Selected Export Package
    Unticked everything
    Then Ticked everything Starting Assets/AI
    and exported to my loacal disk called "old mech AI"

    Then I Imported "old mech AI" into a new project and it worked !!

    So To summerise

    If I download it from the asset Store it doesn't work cant use it.
    If I use an old version which is the same version I think seeing as it hasn't been updated (officially) it works

    Also when Install Examples (on the version from the asset store) I get a new menu option "Mobile Input"

    What is going on? am I going mad??

    Anyways I've got a work around I can continue for now.
    But we need a stable update soon please.
     
    Last edited: Mar 8, 2014
  10. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    From your video it is all working fine. Please checkout the included documentation file, there are also video tutorials to get started. The properties are for each state. So creating a new state for example Follow and selecting the state will show you properties that you can set in the inspector. I removed the automatic adding of NavMeshAgent, because this system can be also used without this component for 2D stuff, and soon also just with other things like Rigidbody and Character Controller(without pathfinding).
     
  11. Also

    Also

    Joined:
    Jul 17, 2013
    Posts:
    16
    Yeah, I bought that script pack some time ago and I still have some of the files imported (the Attribute file is one of them). I'll delete it and see if it works.

    Thank you very much!
     
  12. Also

    Also

    Joined:
    Jul 17, 2013
    Posts:
    16
    It's working now!

    Thanks Zerano and Mmmpies!
     
  13. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    365
    Wow I know how the confusion happened

    I don't watch Youtube videos online I download the useful ones to my PC so I can scrub through and jump to any point in the video instantly without streaming.

    So I have a large video tutorial library with a folder for Mechanim AI and I have the following HD videos:
    Mecanim AI System.mp4
    AI System - Enemy Damage.mp4
    AI System - Custom Condition.mp4
    AI System - Basic Information.mp4

    Now I know everything is "in the cloud" these days but youtube has got slower over the years and is annoying when you want to find a particular point in a video.

    I cant find the above videos on youtube anymore so I presume they've been removed, which is Good because there is nothing worse than an out of date video tutorial for causing confusion.

    This is why I asked the question "is there a new version out? " on page 15 of this thread.

    So it seems the PDF has changed which I didn't realise and therefore didn't re-read, and my video tutorials are out of date.

    And you've fixed the Editor window bug !

    It seems like there was a new version after all and it happened between page 13 and page 15 on this thread.
     
  14. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Ahh okay yes, i have reworked the pdf and added new tutorial links for youtube. The next version will also not contain the examples but you will get the links to the examples in the pdf. I decided to do it this way, because with each example the unitypackage gets bigger and if you not need them you should not download them for waste.
     
  15. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    365
    Ohh WOW - you've re-done the video tutorials, that's fantastic

    I am very happy you are updating the documentation with your product (many developers don't) and it gives me great confidence in your software.

    I can see now it was my fault for being a luddite and not reading things properly

    Thanks for your great support.
     
  16. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    365
    I have a question and wondered if anyone had any ideas:

    I want to use lineOfSight when the enemy is following the player
    But I don't want the enemy to stop when it looses line of sight, I want it to go to the location vector of the player the last time it saw them.

    In essence I want to follow state not to be following the player but going to the place it last saw the player.
    So I think its a case of storing the vector 3 of the player each time line of sight is true.

    Could that be done in AI for mechanim or do I need to write a script and reference it in AI for mechanim

    My Reason
    I want the player to be able to run around a couple of corners and hide, and the enemy to loose the player and give up the chase.

    any help greatly appreciated.
     
  17. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Hello, it will be possible in the next version, i already added actions for this. The last thing i want to put in version 1.3.2 is the patrol option we spoke about a few pages back, then i can submit the update.
     
  18. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    Hello folks,

    I'm having an issue with my character sliding forward for another 1-2 seconds while in its Idle state after its transitioned from a follow state. It doesn't happen all the time but maybe 50% of the time. Any ideas what this could be due to?

    Edit: Ok so I think its Nav mesh related, the red nav mesh line forces the character to walk to its end point when it looses view of the target, even when it has transitioned into idle. Is this a bug or any way to get round it?

    Is there a way to test velocity in conditions? I can GetProjectedVelocity but have no way of using that value with Conditions?
     
    Last edited: Mar 10, 2014
  19. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    Zerano,

    I have written a custom condition to check the player health in 1.2. How do you achieve this in 1.3.1. ? Is there any simple way to do this ?

    note : AIController is on the enemy.

    Thanks
     
  20. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    It is not possible in this version, but i already added this, i hope to submit the update tommorow.
     
  21. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    You can just write translate your custom conditon. You need just to derive from BaseConditon and not from CustomCondition.I have not worked on it yet, but i will try to find a way to get/set properties in a generic way.
     
  22. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    I’m having a similar issue. About 30% of the time, my enemy AI is skating when transitioning from Follow to Attack (via Idle). This causes it to end up on top of the target character whie it executes the Attack animation.

    It does seem to be related to the navmesh. If the target only runs a short distance in a straight line, it doesn’t seem to happen - the enemy AI stops at the correct distance before attacking.

    Any ideas? This behaviour occurs even if I just paste the Ratkin Slave into my scene (i.e. using its Mecanim animator and AI controller).
     
  23. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    Sometimes an arrow icon for a transition is not drawn.

    See the following:

    $bug_no_arrow_in_transition.png

    Repainting with moving the Idle or MoveTo state makes the arrows to be shown again.

    [NOTE]
    It's not a AssetStore version but the svn version.


    -Kim
     
  24. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    There is null reference exception with adding AIRuntimeController without assigning an AIController asset.

    $airuntime_without_aicontroller.png

    Got the following error:

    It may need to check null value of the AIContorller instance, see the patch:

    Code (csharp):
    1.  
    2. Index: AIEditorWindow.cs
    3. ===================================================================
    4. --- AIEditorWindow.cs   (revision 3)
    5. +++ AIEditorWindow.cs   (working copy)
    6. @@ -19,6 +19,9 @@
    7.  
    8.     public static void Init (AIController controller)
    9.     {
    10. +       if (controller == null)
    11. +           return;
    12. +
    13.         editor = (AIEditorWindow)EditorWindow.GetWindow (typeof(AIEditorWindow));
    14.         editor.controller = controller;
    15.         editor.title = controller.name;
    16.  

    It's not a AssetStore version but from svn repository one.


    -Kim
     
  25. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    I am going to take a closer look at it today.

    Can you please update your local copy, because i can remember that i fixed this already. Please let me know if the bug happens on the latest version.
     
  26. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    Hi Zerano

    Just to help you out this is a simple setup that replicates the sliding in idle state.

    $AI_test.png <--------- should be an image

    As the player moves out of range the AI will transition to idle but will 50% of the time carry on moving/sliding to the last place it saw the player.

    Hope this helps!
     
  27. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    You have very strange conditions, in the idle you check if the distance is less then 4 -> transition to follow. Then in the follow state you check if the distance is greater then 10 -> transition into idle state. This combination will will make the enemy walk into the player.
    Maybe you want to stop the movement if the distance is less then 4. Then you have to set this condition in the follow state.

    Are you trying to make maybe something like this? Sorry the gui changed a little bit, but the conditions gui is the same.
    $11-03-2014 11-57-16.png
     
  28. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    Hi Zerano,

    Thanks for looking at this :) I'm trying to get the AI to only follow if it gets within range and to "lose interest" if it gets to far away. Your example is not what I was going for, it'll just follow the player until it gets within range?
    I guess I am using the conditions in a way that was not anticipated ;)

    I might try using triggers instead to get the same effect.
     
  29. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    This is fully possible, you would need to create an "or" condition. Simply make a second transition from follow to idle.
    $11-03-2014 13-21-29.png
     
  30. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    Although when the condition "distance greater than 10" is met and it goes to idle I'll get the same issue with the enemyAI sliding in "Idle" to the last target position 50% of the time.
    The example I posted was a test to show the issue I was describing in the simplest way possible. The AI I've done works the way you suggest and actually works quite well I just have the sliding issue that I was trying to solve.
     
  31. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    I played my and your example many times and could not reproduce it, but i used not version 1.3.1 . :(
     
  32. Darren-R

    Darren-R

    Joined:
    Feb 11, 2014
    Posts:
    66
    Ah, ok well there's got to be something I'm doing differently then. Cheers for the checking it out, I'll hack something together to stop it from happening ;)

    Edit: I fixed it by putting a blank Follow state in between my Main Follow and idle states, I guess this resets the navmesh and forces it to stop :)
     
    Last edited: Mar 11, 2014
  33. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
  34. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    Where do you want it to be uploaded?

    My account for the svn repository is limited to write the changes, it is only possible to read.

    Anyway, I'll drop the patch file via your freenet.de email account.


    Regards,


    -Kim
     
  35. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Hey thank you, but i wanted to know if the error still exists if you update your svn to the latest version.
     
  36. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Hey kotor, i do not know if you have svn access, but this is possible out of the box now with the GetProperty action. You can get more information about it here. If you do not have svn access contact me and i can send you the update or give you svn access.
     
  37. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    Thats great. Thank you. I will try it.
     
  38. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    Where is the link to get to svn ?
     
  39. kodmistrz

    kodmistrz

    Joined:
    Jun 11, 2013
    Posts:
    12
    I don't see Mecanim parameter name :( Example on screen below.

    $ai_mecanim.png
     
  40. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    365
    Request for UFPS Tutorial / Example:

    I'm trying to get the damage working with UFPS and AI for Mechanim
    I've done the following
    Create a new layer at position 30 and call it LocalPlayer. Use this layer in the LineOfSight condition mask.
    Disable hasCollisionTrigger in the Vp_FPController script under the physics.
    Add a new Capsule Collider tot he player and set isTrigger to true
    Add UFPSDamageReceiver to all enemies that should reduce an attribute.
    it is not working the rat tries to hit me but causes no damage.

    Also there is no damage in the UFPS Example
    I was hoping to see how it was done in The UFPS Example but it isn't working anymore
    I've created a new project
    Installed UFPS
    Installed AI System
    Clicked install UFPS Example
    Clicked install Examples
    Loaded up the AI Example scene and I get the following problems.
    Animator has not been initialized on the 3 Bots (missing animator controller warning) (not a problem I can remove from the scene)
    The Robot Kyle chases and shoots at me causing NO damage
    Also if I get too close to Robot Kyle I get an error MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.

    I can damage the Robot Kyle with my mace
    I can take damage from explosions

    So I'm a bit stuck
     
  41. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    This is an external system, please pm me a username/password that you would like to use and i will add you and send you the link where you can check out it.

    Well the problem here is then that your animator controller does not contain an integer parameter. i know i need to add a message and will do so. Maybe you are trying to set a float?
     
  42. kodmistrz

    kodmistrz

    Joined:
    Jun 11, 2013
    Posts:
    12
    No... My character controller has integers, booleans, floats... Still parameter name no showing...
     
  43. kotor

    kotor

    Joined:
    Dec 3, 2013
    Posts:
    140
    Zerano,

    I have created a EnemyDwarf AI Controller. I want to use the same AI Controller in my different scenes. I Can't use it since the patrol points will be different in different scenes. The only way I can use it to copy it and use a different patrol points. Do you have any other suggestion ?

    Thanks
     
  44. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Ohh okay i will look into it. Does it work with SetFloat or SetBool?

    Currently this is the only way to work with when working with patrol :(

    I realy would like to ask you to post your questions or bugs in the support forum.
     
  45. kodmistrz

    kodmistrz

    Joined:
    Jun 11, 2013
    Posts:
    12
    Unfortunately no :(
     
  46. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    365
    Where is the support forum? I looked for one, I do apologise if I posted my question in the wrong place. Is this the support forum?
    I'm a little bit confused.
     
  47. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
  48. kimsama

    kimsama

    Joined:
    Jan 2, 2009
    Posts:
    166
    I've checked the bug with 1.3.2b from the svn's latest code.

    It's gone now, thanks for your proceeding.


    -Kim
     
  49. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    I have recorded 2 new video tutorials on how to apply damage to the player from a projectile and from a meele attack in UFPS.
    Forum Post
     
  50. uansgheps

    uansgheps

    Joined:
    Dec 5, 2012
    Posts:
    11

    Great Zerano and Mmmpies!
    I had same problem because also in the code that I had developed I had a Attribute class that was incompatible with the System.Attribute class; adding System.Attribute like Zerano had suggested works!
    Better solution and a "best practice" is adding a namespace for all code that I developed..