Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Event system for Mecanim

Discussion in 'Assets and Asset Store' started by G1NurX, Dec 25, 2012.

  1. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Pack characters, animations, animator controllers and the GO attached Mecanim Event Data into one assetbundle.
    In this case, you should call MecanimEventManager::SetEventDataSource(MecanimEventData dataSource) instead of MecanimEventSetupHelper - you don't need it any more. the dataSource should be the Mecanim Event Data prefab in assetbundle.

    You can't separate those four within different assetbundles. Otherwise, Mecanim can't work correctly - it's not my fault ;-)
     
  2. broken

    broken

    Joined:
    Mar 14, 2013
    Posts:
    30
    Well, I can remove the MecanimEventSetupHelper GO from the scene and the scene of dependency animations will not be (Asset Bundle scene).

    As for the fighters bundle, if I have lot COMMON animations for all fightres, one COMMON AnimatorController, and one prefab (Mecanim Event Data), there is no problem that it will not be duplicated in a bundle of different fighters?

    That is,
    Fighter 1 Bundle
    1. Character_1
    2. Animations SET_COMMON
    3. Animator Controller FIGHTER_COMMON
    4. GO with EVENT_DATA_COMMON

    Fighter 2..N Bundle
    1. Character_2..N
    2. Animations SET_COMMON
    3. Animator Controller FIGHTER_COMMON
    4. GO with EVENT_DATA_COMMON

    Yes, I've read that Mecanim there is a problem, let's see what will happen in the next versions.

    Thanks!
     
  3. DDP

    DDP

    Joined:
    May 17, 2012
    Posts:
    15
    Hi G1!

    If i click "Window -> Mecanim Event Data Transfer", I can see this window:
    $mecanimeventtransfer.png

    What's expected in the "Transfer From" and "Transfer to" fields?

    Also, is there any documentation I missed for your plugin? The plugin is great, but it would've been easier with a quick step by step guide or something.

    Thanks!
     
  4. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    This is hidden feature of this asset ;)
    It's useful for earlier customers

    In the latest version, multiple data source was supported that you can store events in several data nodes.
    This data transfer tool is used to copy/cut event data from one node to the other.

     
  5. rocket5tim

    rocket5tim

    Joined:
    May 19, 2009
    Posts:
    233
    Hey, looks like the plugin is broken in Unity 4.2. I'm getting a ton of errors in the console like...

     
  6. Crazy Robot

    Crazy Robot

    Joined:
    Apr 18, 2009
    Posts:
    921
    Same here,

    On the first post the Dev states he sent in an update to the Asset Store, but this is intertwined in my game, so I'm at a work stoppage until it's fixed. I sent the Dev an email, hopefully I can get a hot fix now.
     
  7. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,042
    Same, email sent.
     
  8. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Dear my customers,

    The version compatible with unity 4.2 is available in asset store now.
     
  9. homeros

    homeros

    Joined:
    Dec 23, 2009
    Posts:
    121
    I hadn't updated the plugin for a while and had to update today because of 4.2 compatibility. I must say the editor is much more easy to deal with compared to my older version. Keep up the good work mate.
     
  10. John-Gray

    John-Gray

    Joined:
    Nov 27, 2012
    Posts:
    133
    Hi.

    I build my Unity projects using Visual Studio 2010 and after the update for 4.2.0 I am still getting a lot of errors relating to the Editor/Inspector files for the Event Editor even though they do not appear in the Unity Editor. The project still compiles but I have a feeling something could be wrong with the inspector files.

    I have put the errors into an Excel sheet here:

    https://www.dropbox.com/s/tvp75f8moxxh8bb/EditorErrors.xlsx

    Thanks!


    View attachment $EditorErrors.rar
     
  11. Katarak

    Katarak

    Joined:
    Feb 19, 2013
    Posts:
    13
    After the update to 4.2 I find the Event System Editor is absolutely slow.... eating up about 15% cpu on my machine. Makes it impossible to edit values or add new controllers, very very laggy.
     
  12. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    I think your c sharp solution was corrupted. You could bakup your project and delete all these solution files generated by unity.Then re-open the project to make unity to generate them again.
     
  13. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    I'm sorry.
    I only changed some APIs to make it compatible with unity 4.2. Your problem is strange.
    In fact, the new release was developed months ago when 4.2 was still in beta. I haven't received any error / performance problem from my parteners.

    Is it still lag even in a new project ?
     
  14. Katarak

    Katarak

    Joined:
    Feb 19, 2013
    Posts:
    13
    Is it possible it is because of the amount of controllers and events we have?
    in 1 eventDataprefab we have 9 controllers listed. Each with about 10 layers and some of these layers have over 20 animations. and then events... 50 per controller? at least.

    I can try with a new project and see what happens. Your tool is great btw.
    What would be great is the possibility to duplicate events on new controllers. All our controllers follow the same names (just different rigs and avatars) and we need to duplicate the events for everyone. My current solution is to open the prefab in a text editor, copy, and paste then change the GUID for the proper one.
     
  15. lighting

    lighting

    Joined:
    Dec 21, 2011
    Posts:
    42
    Hi,

    I'm using your system very intensively and it works very well with many events put in. However, there is one thing that doesn't work - when events are being placed near to animation end (timing almost 1.000) the events don't trigger - functions in code are not being called. It there any way to fix it are have walkaround ?

    Thank you,
    Maciej Wdowiarz-Bilski
     
  16. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    1) You could split your data into several data node by using Mecanim Event Data Transfer tool in menu - Window/Mecanim Event Data Transfer. First , create a new empty data node. Open the data transfer window. Fill the Transfer From field with your old data node and fill the Transfer To with the newly created data node. Toggle on the data want to copy. Finally , click the Transfer button. At this point. the data entry toggled on is copied to the newly created data node.

    If you want to delete some data entry, drag the data node to the Transfer To field. There is X button ahead each data entry of Transfer To data view. Click the X button will delete this entry from the data node.

    In this way, you can organize your data. In order to using the newly created data nodes, click the GO attached MecanimEventSetupHelper.Make sure the Data Source field is empty and drag those newly created data nodes to the Data Sources array. All these data will be merged at runtime.

    2) There is a tool to copy data from controller to controller. It looks a bit ugly so I didn't upload it. These tool is only used by myself :)
    I will merge it into trunk and upload it some day.
     
    Last edited: Jul 26, 2013
  17. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Try to toggle on the Critical option in the popup window. This option make sure an event will must be raised event the state was interrupted.
    I barely put an event near to the end of state. It can be missed when transition exists.
     
  18. Rami.Sleiman

    Rami.Sleiman

    Joined:
    Mar 20, 2013
    Posts:
    1
    Will we be seeing support for setting events in blend trees?
     
  19. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Setting events in blend tree is always being supported.

    For blend tree that all animation clips were made in to be synchronized in normalized time, just add a event as normal one.
    For blend tree that animation clips were not synchronized or events would be distinct in clips, you should use the conditional event feature.

    And you can adjust the preview of blend tree state in the inspector.
     
    Last edited: Aug 11, 2013
  20. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67

    Hi Katarak,

    The feature you mentioned it is available now. There is a `Tools` button in the editor window. Click it will open up a menu that provides copy and paste tools.
     
  21. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Hey Gin, long time no speak!

    I have a tiny request, that is unless I'm doing something incorrectly.

    I want to have Conditionals that have the option to be ANY / ALL / OR. Right now I have my events set up on my 2D Blendtree, which has both walk and run animations for each direction (Forward, backward, left, right), and with different footstep timings between the two sets.

    I need to be able to create a Conditional for each such as:

    Walk Footstep Conditions:
    XPos - Lesser Than : 0.45
    XPos - Greater Than : -0.45
    YPos - Lesser Than : 0.45
    YPos - Greater Than : -0.45

    Run Footstep Conditions:
    XPos - Greater Than : 0.45
    XPos - Lesser Than : -0.45
    YPos - Greater Than : 0.45
    YPos - Lesser Than : -0.45

    As you can see, all have to be true for the event to fire, but I merely need ANY one of them to be true. The problem here of course is that in many cases some will be True in the Walk Conditions, and some True in the Run Conditions causing another set of problems. I suspect this would mean each condition or the subsequent event would require a Priority setting thus denying Events of lower priority from ever firing (e.g. a Run event would have priority over the Walk events)

    Does this make any sense or is it just late for me and I'm just too tired to ask for this correctly? :D

    Thanks man!!

    -Steve
     
  22. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    I could just as well do this through script, simply figuring out what I want to do with the triggered events. In other words I'll have a plain 'Footstep' event for both walk and run all together, not worry about conditionals and just figure out in my script if the character is walking or running. I don't foresee any issue with that and should work yes?
     
  23. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Also the ability to Disable/Enable events...

    ...right now I'm having events firing when they shouldn't, probably due to transition states, but again the 'weight' of the subsequent sequence being blended to is very low. In other words the initial animation is playing (e.g. Jump_Landing) and the animation it transitions to isn't necessarily playing (Movement), but it's events are still firing even when the player isn't in fact moving forward.

    I need to debug this but I can't easily without creating unique Events with Strings, which is 'doable' but inconvenient, moreso if and when the amount of events I need goes up. So a simple checkbox to toggle an event on/off would help.

    Thanks again Gin!

    -Steve
     
  24. kira_2KC

    kira_2KC

    Joined:
    Sep 3, 2013
    Posts:
    1
    it seems that when i load animator with controller from assetbundle, the event system didn't work. because:
    int animatorControllerId = entry.animatorController.GetInstanceID();
    animatorControllerId changed?
     
  25. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Hi Steve,

    It won't be an easy job to organize those logical operation well on gui. It can be much more complex than script in code.
    This is my idea, that done comparison in event handler.
    As soon as received a footstep event, you can get the xPos and yPos values from AnimatorController.
    Which sound should be played can be decided basing on the two value.

    I will add the disable/enable event feature in the next release.
     
  26. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Hi
    Animator controller and event node should be in one bundle. Otherwise, instance id will be mismatched.
    In the next release, a new emitter will be added whose data source can be separated from the global data source so that you can build an animator controller and its event data into one asset bundle.
     
  27. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    I agree. When I thought about this I realize that either you or I would have to pull that data out and discern if and when to fire an event, and it's not an issue for me to do it in script. I still think have the option to do AND/OR/ALL on the conditions could be helpful, but not necessary perhaps.

    Thank you for considering the Enable/Disable option! :D

    Later Gin

    -Steve
     
  28. yumupdate

    yumupdate

    Joined:
    Nov 20, 2012
    Posts:
    29
    Hi, G1!

    I'm interested in using your plugin, but I wanted to know about basic functionality before I jumped on the purchase. I'm currently using curves to fire off events, but it's been completely unreliable and dependent on frame rate ... more specifically, if the system gets choppy for any reason what-so-ever, there's a chance the trigger doesn't even fire. My question is this: Is your system timer based / guaranteed to fire regardless of frame-rate? Or is it somehow programmatically curve-based?

    Thanks for your time!
     
  29. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Hi,
    It's not curve-based. Events were set to a state in normalized time. In most time, events are reliable except ones defined in a transition. But you could toggle on the critical option to make it never missed even state was interrupted.;)
     
  30. yumupdate

    yumupdate

    Joined:
    Nov 20, 2012
    Posts:
    29
    Sold! Thanks :)
     
  31. yumupdate

    yumupdate

    Joined:
    Nov 20, 2012
    Posts:
    29
    Hello again, G1NurX

    I'm using your event system now (thanks, by the way!) for my project's animation events and I have one scene where the events are working quite well. When I go to any other scenes, however, I get the message "nullreferenceexception: object reference not set to an instance of an object" and it's referring to the Animator (or maybe the animatorControllerId?) that is passed into the script, which appears to be choking on the first IF statement of your plugins CollectEvents function. I have re-assigned both the controller and the animator by following the tutorial again, but that doesn't seem to work.

    The character using the script is a prefab across multiple scenes, but I assigned the proper scripts to the prefab and only used non-scene-specific references in the fields for the Mecanim Event Emitter script.

    Any ideas?

    Thanks!
     
  32. Lork

    Lork

    Joined:
    Jul 12, 2013
    Posts:
    74
    Hi G1NurX,

    I'm getting a problem where events flagged as 'critical' will often fire twice. It seems like the code that determines if an event was skipped is getting false positives and firing the events again after the animation has finished playing even though they already fired just fine when they were originally supposed to.
     
  33. yumupdate

    yumupdate

    Joined:
    Nov 20, 2012
    Posts:
    29
    Ack! I'm an idiot. I fixed it by properly assigning the Setup Helper Script to something that cascades down to all scene via prefab.
     
  34. tmcsweeney

    tmcsweeney

    Joined:
    May 24, 2011
    Posts:
    20
    I was seeing the same lag when opening the events for an animator with lots of layers. Profiling the editor revealed that GetLayer() allocates the layer data every single time it is called, and this was causing the GC to thrash.

    I modified DrawLayerPanel() to cache the layers in the GUI Layout event, and then reuse the cached versions for all other events and this massively improved performance. It could probably be improved further by being even more aggressive with how long the cached layers are kept.

    Patch follows:

    Code (csharp):
    1. Index: MecanimEventEditor.cs
    2. ===================================================================
    3. --- MecanimEventEditor.cs   (revision 645)
    4. +++ MecanimEventEditor.cs   (working copy)
    5. @@ -179,8 +179,11 @@
    6.    
    7.     Vector2 layerPanelScrollPos;
    8.     int selectedLayer = 0;
    9. +
    10. +    AnimatorControllerLayer[] layers;
    11.    
    12.     void DrawLayerPanel() {
    13. +
    14.        
    15.         GUILayout.BeginVertical(GUILayout.Width(200));
    16.        
    17. @@ -188,6 +191,15 @@
    18.        
    19.             int layerCount = targetController.layerCount;  
    20.             GUILayout.Label(layerCount + " layer(s) in selected controller");
    21. +
    22. +            if (Event.current.type == EventType.Layout)
    23. +            {
    24. +                layers = new AnimatorControllerLayer[layerCount];
    25. +               for (int layer = 0; layer < layerCount; layer++) {
    26. +                   layers[layer] = targetController.GetLayer(layer);
    27. +               }
    28. +            }
    29. +
    30.            
    31.             GUILayout.BeginVertical("Box");
    32.             layerPanelScrollPos = GUILayout.BeginScrollView(layerPanelScrollPos);
    33. @@ -195,13 +207,13 @@
    34.             string[] layerNames = new string[layerCount];
    35.            
    36.             for (int layer = 0; layer < layerCount; layer++) {
    37. -               layerNames[layer] = "[" + layer.ToString() + "]" + targetController.GetLayer(layer).name;
    38. +               layerNames[layer] = "[" + layer.ToString() + "]" + layers[layer].name;
    39.             }
    40.            
    41.             selectedLayer = GUILayout.SelectionGrid(selectedLayer, layerNames, 1);
    42.            
    43.             if (selectedLayer >= 0  selectedLayer < layerCount) {
    44. -               targetStateMachine = targetController.GetLayer(selectedLayer).stateMachine;
    45. +                targetStateMachine = layers[selectedLayer].stateMachine;
    46.             }
    47.             else {
    48.                 targetStateMachine = null;
    49.  
     
  35. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Thanks, tmcsweeney.
    It's applied.
     
  36. m.monks

    m.monks

    Joined:
    Nov 6, 2013
    Posts:
    1
    Hi G1NurX,

    I've been working with the event node system (works great!), but I want to do some cleanup and remove some of the animation controllers that I added in the event editor. I can't find any way within the event editor to remove unwanted animation controllers.

    Can you suggest a way to do this?

    Thanks
     
  37. marvelshaan

    marvelshaan

    Joined:
    Oct 22, 2013
    Posts:
    21
    great asset..is there any tutorial videos??
     
  38. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    728
    Well I went ahead and bought this asset since it seems pretty useful and the lack of animation event system for Mecanim is really killing me.

    I followed the instructions on the tutorial PDF file and everything worked fine when I created my first event but now when I open the MecanimEventEditor window I cannot drag the time slider at the bottom anymore. It just doesn't move. And if by chance I manage to drag it the preview window does not update. The red line moves in area at the top of the preview window but the animation itself doesn't update. Which is of course a problem.

    So I would like to know: am I doing something wrong or is this a known problem? Thanks...

    PS: I'm on 4.2.1f4


    Update 1:

    It definitely looks like there's a problem with the connection between Unity's animation preview window and the MecanimEventEditor window. It causes the preview window to stop updating animation even when dragging in the red tick mark.

    The temporary fix I found is to click on the Preview's IK button; it seems to "reconnect" the timeline of the event editor and Unity's preview. But the problems happens again when the Mecanim Event Data prefab is deselected and re-selected.


    Update 2:

    There is another problem when clicking on an animator controller button (in the left-hand column of the event editor): the preview window does not show the proper character. It shows the right animation, but on the character that was previously selected. To get around the problem you need to click on the desired animator controller button, then deselect anything, re-open the event data prefab and only then does the preview window show the correct character. I hope that can be fixed...

    Besides those glitches this is truly a fantastic tool.
     
    Last edited: Nov 11, 2013
  39. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    728
    After using the system for several hours here's a feature request: could you please add a color property to the events tick marks in the anim event manager window? That way you could visually identify at a glance events that are related. It would be a tremendous help, rather than having to pixel-hunt for the right event. Thanks!
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,723
    +1. I think that's a great idea.
     
  41. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    728
    And of course the buttons would reflect the events' color in the timeline. Just for the sake of clarity here's a mockup of what I have in mind:

     
  42. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Sorry.
    Many many web sites (dropbox, youtube, etc.) are blocked in my country. Also, you are blocked to access such web sites in my country. Uploading video via an unstable proxy is horrible. You just can't image it... . Censorship s*cks.
     
  43. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    That's a good idea. Sure to be added.
     
  44. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    It works fine on my computers. I can't reproduce the *bug*.
    How about the example included in the assets. Is it OK, or it went wrong on your computer?

    No customer reported this problem before.

    However, I guess it is your animation (model or avatar) related. As I know some generic type animation can't be previewed correctly. This problem produced by Unity.
     
  45. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    Hi,
    All you need to do is open the tool at 'Window->Mecanim Event Data Transfer'. Drag the data node to the source field and click the "X" button of the controller your want to remove.
     
  46. SteveB

    SteveB

    Joined:
    Jan 17, 2009
    Posts:
    1,448
    Oh boy here we go! New errors courtesy of Update 4.3! (not complaining...this was expected) :D

    If you have quick fixes you can post the code here and we can implement them ourselves.

    Thanks Gin

    -Steven
     
  47. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    728
    @G1NurX: I'm very sorry about the situation in your country with regard to censorship. I truly feel for you man... :sad:

    I will test the problem I mentioned before on the example scenes and let you know the results here. I just want to repeat that this event system is absolutely fantastic because, as you said, it's based on anim states and not anim clips. So you literally create 2 events for foot planting (left and right) and if you have 6 or 10 animations in your locomotion state, all the animation will be able to use those events. It's truly powerful stuff!
     
  48. TheAdam

    TheAdam

    Joined:
    Jul 2, 2013
    Posts:
    4
    regarding the unity 4.3 errors: I'm not sure if GetEffectiveAnimatorController does what GetAnimatorController used to do. I know that I placed it in my code and it allowed me to compile (and allowed my colleagues to continue working), as well as firing off events.
     
    Last edited: Nov 12, 2013
  49. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    728
    Thank you sir, that worked quite well!
     
  50. G1NurX

    G1NurX

    Joined:
    Dec 25, 2012
    Posts:
    67
    As TheAdam mentioned, change GetAnimatorController() to GetEffectiveAnimatorController() will fix the problem.

    New version was uploaded but being reviewed.
     
unityunity