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. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,524
    Alright. Thank you for the reply.
     
  2. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Copy/Paste! : D
    Hardly have time to update before next update comes out, you must work hard on this : )
     
    hopeful likes this.
  3. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    I'm using another asset "Event System for Mecanim" it's using Unity's built-in class "UnityEditorInternal.StateMachine". Since you have named your class "StateMachine", it's conflicting with Unity's version.

    Assets/Output/EventSystem/Editor/MecanimEventInspector.cs(476,25): error CS0118: `StateMachine' is a `namespace' but a `type' was expected
     
  4. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    I fixed the problem by adding UnityEditorInternal.StateMachine to the other package.
     
  5. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Is there a way to listen for a SendMessage event ?
     
  6. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    No SendMessage works the same way as the unity SendMessage.

    You can however listen for a custom event from a script subscribing to onReceiveEvent on the StateMachineBehaviour or even using a condition in diffrent state machines for an event sended by any state machine.
     
  7. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Version 1.6.1
    • AssetCreator helper class
    • Copy/Paste whole state machines
    • Prefereces icon instead of label
    • Custom inspector toggle moved to preferences
    • Fixed transition selected color in light skin
    • Replaced FieldInfoAttribute with DefaultValueAttribute, InspectorLabelAttribute,RequiredFieldAttribute and TooltipAttribute
    • Added ObjectTypeAttribute, you can specify which type the ObjectParameter should have.
    • Removed IsFinished condition - Removed Refactoring fixing tool.
    • Updated all addons with the new custom attributes.
    • Cleanup StateMachineUtility class and comments
    • GetProperty and SetProperty support custom namespaces
    • Fixed InterruptMathTarget and MatchTarget action
     
  8. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    Awesome work zerano!
     
  9. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,224
    Nice to see that this is continually updated!

    I've got a small suggestion: The SetParameter method in StateMachineBehaviour looks like this:

    Code (csharp):
    1. public void SetParameter(object[] data){
    2.   executingStateMachine.SetParameter ((string)data [0], data [1]);
    3. }
    Which is not exactly user-friendly. Why not:

    Code (csharp):
    1. public void SetParameter(string paramName, object paramValue) {
    2.   executingStateMachine.SetParameter(paramName, paramValue);
    3. }
    Whenever I update, I always add the second method, and it'd be nice to see it as a core feature. Wrapping the name and value in an array for them to be immediately unwrapped seems a bit silly.
     
    angrypenguin likes this.
  10. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,224
    Also a BIG HINT TO ANYONE ELSE USING THIS PACKAGE:

    If you need to change one of the included scripts to fit your game, remember to keep an overview of which scripts you have changed! Move them to an own folder or something like that.

    I did not do that, and now it's kinda difficult to update the package. My own fault completely, but I can see other people messing up in the same way. Goo luck!
     
  11. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    Backup before doing anything. Every day before using my project I back it up. Add the date to the end of the zip file and move it to another hd.
    And if you are adjusting scripts or creating your own scenes. Make sure it isn't the place as the originals.
     
  12. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    I'm using Event System for Mecanim - https://www.assetstore.unity3d.com/en/#!/content/5969
    Is it possible to add support for this package?
     
  13. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
  14. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    To be able to receive events that's fired from the Event System for Mecanim. The events are being set by that package within the editor.
     
  15. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    SetParameter has an array to be able to set a parameter using SendMessage. If you are calling SetParameter from script you can call:

    Code (CSharp):
    1. reference.executingStateMachine.SetParameter(paramName,paramValue);
     
  16. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,526
    In addition to this, it'd be nice if we could add a parameter by code.
     
  17. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Sure i can add this, but could you tell me any usage for this? Since you have to reference a parameter in the editor, why would you want to create a parameter by code at runtime?
     
  18. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,526
    For starters, why does it necessarily need to be at runtime? Even at edit time it'd be nice to auto-generate parameters so we don't have to type names in and such.

    Anyhow, my use case is that I've got some custom conditions that optionally use parameters if they're present. I wish to be able to add these parameters at runtime. I could of course pre-add them to every state machine where the relevant conditions are in use, but even that would be a task best automated. ;)

    As it is I only need to set floats at runtime for now, so I've hacked up a little method to do that which on super early testing seems to work:

    Code (csharp):
    1.  
    2. public void AddFloatParameter(string name, float initialValue) {
    3.   NamedParameter parameter = GetPrameter(name);
    4.   if (parameter != null) {
    5.   SetParameter(name, (object)initialValue);
    6.   return;
    7.   }
    8.   parameter = ScriptableObject.CreateInstance<FloatParameter>();
    9.   parameter.Name = name;
    10.   (parameter as FloatParameter).Value = initialValue;
    11.   parameter.stateMachine = this;
    12.   this.parameters.Add(parameter);;
    13.   }
    14.  
    Is there anything in here that's likely to bite me later?
     
  19. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    I do not see any problem here and will add this for all parameters in the next version. I have already an utility class for such things, however it is currently only availible in editor mode, so i will move it to runtime.
     
    angrypenguin likes this.
  20. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    You have now an option to create the parameter if there is none.
    Code (CSharp):
    1. reference.executingStateMachine.SetParameter(paramName,paramValue, true);
     
    angrypenguin likes this.
  21. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,526
    Excellent, thanks!
     
  22. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Version 1.6.2
    • MainToolbar selecting menu picked up the asset in play mode and not the current executed state machine.
    • GetProperty does not require "CanWrite" access anymore.
    • Get and SetProperty action had no option to get/set UnityEngine.Object,i still need to add generic System.object.
    • SetParameter has an option to create the parameter if none exist.
    • Inspector panel tabs for FSM, State and Layers(coming soon) settings
    • States can have diffrent colors(except AnyState and DefaultState)
    • Improved StateMachineGUI performance using simple cache dictionaries.
    I just want to remind you again to review this asset, I am open for any suggestions and requests. You can contact me by email, pm, forum and skype. I would appreciate a written review in the asset store, not just the star rating. Thank you very much.
     
    angrypenguin likes this.
  23. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    For some reason I'm getting this strange error from the Default Example.

    Assets/State Machine Examples/Default Examples/Waypoint System/Scripts/Actions/GetWaypoint.cs(10,18): error CS0246: The type or namespace name `FieldInfo' could not be found. Are you missing a using directive or an assembly reference?

    The same errors for the Legacy Animation package - Actions and Conditions for the legacy animation system.
     
  24. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Do you downloaded and imported the updated addons and examples?
     
  25. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Version 1.6.3
    • Fixed folout in GlobalParameterEditor after reload.
    • Copy/Paste/Replace for whole condition list when right clicking on header.
    • Refresh condition list, when removing a transition
    • SendEvent accepts parameters of type float, int, string and UnityEngine.Object, which makes it very powerful receivable "SendMessage" action.
    • Transform.Parent sets the default target parameter to Owner
    • Group popup for existing groups in GlobalParameterEditor
    • You can change group afterwards in GlobalParameterEditor
    • Movable parameteres in GlobalParameterEditor
    • Fixed bug when setting a Vector3 to a global parameter
     
  26. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
  27. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
  28. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Ok, I just downloaded the new default example and it works without any add-on. Since there are so many updates to AI for Mecanim, I don't know when I should download a new version of the Default example. The default example is a 95meg download and to do this for each update on a slow internet line is a bit much. Is there a way to let us know when we really need to download a new Default example?
     
  29. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Yes i will put a date on the examples. I also always write here in this thread when the examples needs to be redownloaded. But the bigest changes are done so you should not need to download the examples anytime soon(I hope :D).
     
  30. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    Thanks, I also re-downloaded most of the AddOns just to be on the safe side. Please put a date or the version of AIForMecamin that the add-on supports.
     
  31. RealSoftGames

    RealSoftGames

    Joined:
    Jun 8, 2014
    Posts:
    220
    Hello, i need a little help understanding some things, i have a Enemy Character i brought form the asset store, it comes with animations, but im following you State Machine - Random Walk video but it does not use the animation what could be causing this, Ai seems to be the hardest part of Games development and i haven't been able to grasp it yet =/
     
  32. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    @Zerano is it possible to have a basic networked AI example using photon ? before with rpg kit we had some examples with stats sync. but since you updated to the new AI system examples are gone
     
  33. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    It uses animations on an existsing animator controller, you would need to follow the tutorials on how to create an Animatior Controller. There are many tutorials out for this.
    Here is a short one:
     
    RealSoftGames likes this.
  34. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Using custom events can be pretty powerful.
     
  35. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Version 1.6.4
    • Reset transition index to zero when removing a transition
    • uScript compatibility
    • Fixed bug getting List using GetProperty
    • List actions support System.object
    • Fixed harmless warnings when an action has SystemObjectParameter or ListParameter
    • New action System.GetObjectProperty, you can grab any property/field from any class even if it does not derive from MonoBehaviour.
     
  36. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Version 1.6.5
    • Action Browser
    • Condition Browser
    • Added more input conditions
     
  37. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,643
    When I install this I get two errors:

    Assets/State Machine/Scripts/Actions/Time/GetTimeInfo.cs(61,50): error CS0117: `UnityEngine.Time' does not contain a definition for `unscaledDeltaTime'

    Assets/State Machine/Scripts/Actions/Time/GetTimeInfo.cs(64,50): error CS0117: `UnityEngine.Time' does not contain a definition for `unscaledTime'

    How can I fix these?
     
  38. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Update unity to at least the minimum required version, which is currently 4.5.2
     
    hopeful likes this.
  39. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Hmm, any reason why you only check the last agent for != null? Seems a bit strange to me?

    Code (CSharp):
    1. public override void OnAnimatorMove ()
    2.         {
    3.             agent.updateRotation = !value.Value;
    4.             if (value.Value) {
    5.                 agent.transform.rotation=animator.rootRotation;
    6.                 if(agent != null){
    7.                     agent.velocity = animator.deltaPosition / Time.deltaTime;
    8.                 }
    9.             }
    10.         }
    Edit: A small recomendation might also be to add an agen.hasPath check to the wander script? At the moment the agent loves to lock himself in corners : p
     
    Last edited: Oct 8, 2014
  40. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Stupid mistake sorry.
     
  41. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    Hey Janson,

    Are the examples updated to reflect the latest changes in the AI Mecanim as well as in the Ultimate FPS? (in case it is needed)
    Let me know so I download them today.

    Thank you
     
  42. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    They are all updated.
     
    primus88 likes this.
  43. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    Nope. The examples were not updated to the latest, massive Ultimate FPS update.
     
  44. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Ahh there was an update for UFPS, okay have not checked it yet.
     
  45. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,224

    Why not both? We have method overloading, so this would works just fine:

    Code (CSharp):
    1. public void SetParameter(object[]){
    2.   ...
    3. }
    4.  
    5. public void SetParameter(string paramName, object paramValue) {
    6.   ...
    7. }
     
  46. Arbelzapf

    Arbelzapf

    Joined:
    Sep 30, 2013
    Posts:
    58
    The parameter conditions (for example Parameter.CompareBool) don't seem to serialize properly. I am running Beta 4.6.

    The selected parameter does survive the switch from editor to play mode, but when it goes back to the editor, it is unselected again, indicated by the red bar.

    Is this a known issue?
     
  47. DevionGames

    DevionGames

    Joined:
    Feb 22, 2010
    Posts:
    1,624
    Going to check this thanks for reporting!
     
  48. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,224
    Hi, another piece of feedback!

    The BroadcastMessage action has a list of possible types of message parameters. As of now, they are int, float, string, and object. It would be nice if you could select all the possible parameter types - especially Vector2, Vector3 and bool. As of now, doing stuff like broadcasting the AI's direction (Vector2/3) to attached behaviours can't be done through the BroadcastMessage method.
     
  49. Ramsdal

    Ramsdal

    Joined:
    Oct 18, 2013
    Posts:
    251
    Hi Zearno, could you update the UnityGui 4.6 actions/conditions pack, the changes from FieldInfoAttribute in version 1.6.1 has not been made in the pack. I have changed it myself and it seems to work, but would be nice to get an "official version".

    Also this thread has not seen much activity lately. I can not find this anywhere so I ask here - any plans on supporting unity 5? :)
     
  50. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    269
    Hello Zerano,
    Hope you're doing fine.

    I was just going to ask the same thing as Ramsdal did :)
    Do you have any plans to support Mecanim behavior scripts in Unity 5?
    or a general update for Unity 5?
    Thanks