Search Unity

Animancer - Less Animator Controller, More Animator Control

Discussion in 'Assets and Asset Store' started by Kybernetik, Oct 8, 2018.

  1. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    The way the Weapons example works has each attack start fading back to Idle and but start the next attack in the combo if you attack again during the fade, so the ...States.Current will be the Idle animation when you're re-entering the AttackState. So you'd need to store the attack animation you play each time and check that instead of the current state.
     
  2. AnemicPizza

    AnemicPizza

    Joined:
    Aug 17, 2017
    Posts:
    6
    Oh I see, I should've checked what State I was in during each of the checks, didn't notice it was always in Idle State while it's in the AttackState.cs
    I'll probably put this on hold for another time. Thanks for the help!
     
  3. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    animancer.Playable.PauseGraph();
    will prevent it from updating on its own.

    And
    animancer.Evaluate();
    should do the same thing that
    animator.Update();
    normally does.
     
  4. Ell223

    Ell223

    Joined:
    Jan 27, 2014
    Posts:
    15
    Thanks, that seems to have done the trick.

    Sorry accidentally deleted my original post as was going to repost it rephrased as thought I had worded it a bit confusing, and didn't see your (very quick!) reply before I did. Thanks again.
     
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
  6. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
  7. Egnech

    Egnech

    Joined:
    Aug 27, 2015
    Posts:
    27
    Hey there!
    I'm new to Animancet, and so far I'm very happy with it!

    Only thing I'm struggling now is build in FSM, I can't find a correct approach for my situation. So maybe some one can suggest couple ideas ;)

    I need to implement a Gun Weapon behaviour for the player:
    - pull out the gun when player press the Button
    - be able to move with the gun pulled
    - aim (additive animations on a separate layer)
    - shoot action
    - and finally: hide a weapon when player release the Button

    I know how to do all of this separately, and my question is - what is the right way to wrap it in FSM?
    Should I have a separate states like - PullWeaponState (HideWeaponState), GunLocomotionState (+ aiming), and FireGunState? But, maybe I'm overcomplicating thing? :D

    Other way I put everything into one uber state, like - GunWeaponState. And control everything inside it. The down side of having one state is that I will not be able to use build in action buffer, for firing the gun. And I feel that it is a bit messy approach, because the can be too much code for one class.

    I'll appreciate any suggestions!
     
  8. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    If you're supposed to be able to use guns freely while doing any locomotion stuff, you could give each character two state machines: one for locomotion (move, jump, crouch) and one for the upper body (change gun, aim, shoot).

    Or if all your gun actions are supposed to take over from your regular actions, you could make a GunWeaponState which contains its own state machine to manage the current gun state.
     
  9. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    184
    https://kybernetik.com.au/animancer/docs/examples/fine-control/doors/
    It's a question about an example of a document.

    I made a new one and prefabbed it, but there was a problem.
    This problem is also reproduced in the example project.
    If you prefab the doorway (1) of the 02 Doors project(Drag), the following error occurs.

    upload_2021-7-14_9-27-39.png

    When playing, the following warnings and errors occur.

    upload_2021-7-14_9-27-33.png

    Additionally
    There is a slight difference between the script and the documentation included in the package.
    This doesn't seem to cause a big problem, but basically, can I say that the script of the package is a more refined version?
     
  10. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    If you have Animancer Pro you can apply the fix to AnimancerUtilities.EditModePlay that I described in this post. Otherwise in the Doors.OnValidate method you can just put
    UnityEditor.EditorUtility.IsPersistent(this) return;
    at the start of the method to make it do nothing when it's a prefab.

    The script in the package should match the one in the documentation except that the documentation shows it without the namespace since the extra indentation is unnecessary and doesn't contribute to the purpose of the example and the documentation has all the comments removed since everything is explained properly in the text. I can see that I also reversed the if statement in the Interact method because it makes more sense to handle door opening before closing and must have forgotten to update the documentation. So yeah, if I make improve something and forget to update the documentation then the script in the package would be better.
     
  11. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    184

    upload_2021-7-14_9-56-4.png

    upload_2021-7-14_9-56-19.png

    Is this the right way to fix it?
    Errors and warnings still occur.
    Even if an error occurs, it appears to be operating normally in play mode.
    But I'm afraid this will cause a problem.
    Is there any special reason why this modification is not reflected in the official patch?

    Basically, is it wrong to prefab objects containing animancer?
    Not using prefab is a hard-to-understand workflow.
    What is the correct workflow for creating (using) prefab with animancer?
     
  12. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    My bad, the Door script doesn't use EditModePlay so you'll need to call EditorUtility.IsPersistent in the Door.OnValidate method:
    Code (CSharp):
    1.         private void OnValidate()
    2.         {
    3.             if (_Animancer == null ||
    4.                 _Open == null ||
    5.                 UnityEditor.EditorUtility.IsPersistent(this))
    6.                 return;
    7.  
    8.             // Delay for a frame. Otherwise Unity gives an error after recompiling scripts.
    9.             UnityEditor.EditorApplication.delayCall += () =>
    10.             {
    11.                 if (_Animancer == null ||
    12.                     _Open == null ||
    13.                     UnityEditor.EditorUtility.IsPersistent(this))
    14.                     return;
    15.  
    16.                 Awake();
    17.             };
    18.         }
    The only reason those fixes aren't in the latest version is because I haven't released an update since the issue was discovered. They'll be fixed in Animancer v7.0 which I hope to release within the next few weeks.
     
  13. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    184

    Thank you for your prompt reply.
    The problem has been resolved.
     
  14. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    I'm still pretty new to Animancer, but I think I may have run into a bug.

    I'm animating hands for a VR project. Using a set of layers each with a single pose, I manually manipulate the weights to get the blend I'm after. I initially set up the layers, like so:

    Code (CSharp):
    1.         private void Start()
    2.         {
    3.             _hand.Layers.Capacity = 6;
    4.             _open = AddPose(0, _openPose, 1f);
    5.             _fist = AddPose(1, _fistPose);
    6.             _point = AddPose(2, _pointPose);
    7.             _okay = AddPose(3, _okayPose);
    8.             _gun = AddPose(4, _gunPose);
    9.         }
    10.  
    11.         private AnimancerState AddPose(int index, AnimationClip pose, float weight = 0)
    12.         {
    13.             var state = _hand.Layers[index].Play(pose);
    14.             state.SetWeight(0f);
    15.             return state;
    16.         }
    Then in the Update, I manipulate the weights of each with:
    Code (CSharp):
    1.             state.SetWeight(weight);
    2.  
    The result is that the hand transitions nicely between the base layer and the last layer added function, but all other layers are resulting in the base animation. If, for instance the "okay" pose on layer 3 should be playing, the hand plays the "open" pose.

    I have verified that the total of all weights being set is always 1 (+/- the usual floating point inaccuracy). The runtime info in the Animancer Inspector confirms that layer weights are being set as intended. But even when it shows e.g. the "Fist" pose has a weight of 1.0 and all other layers have a weight of 0.0, the hand is in the base "Open" pose.

    Swapping the "Okay" and "Gun" layer indices, the hand does the same, transitioning only between Open and Okay.
     
  15. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    Clarification... turns out the base player isn't playing either. The hand model is transitioning between the pose of the last layer set and whatever pose the model was saved in.
     
  16. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
  17. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    I can see a few minor issues with the code you posted, but nothing that seems like it would cause the issue you're describing. If you post some screenshots or video I might be able to spot something you missed, but otherwise if you want to create a minimal reproduction project and send it to animancer@kybernetik.com.au I'll be happy to take a look at it for you.

    Also, these are the issues I noticed:
    • You're setting the layer capacity to 6 but only creating 5.
    • AddPose doesn't actually use the weight it's given.
    • Rather than calling Play and immediately setting the weight to 0, you could just call CreateState.
     
  18. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Actually, you said you're setting the state weights but what about the layer weights? Are they all kept at 1?
     
  19. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    I'm reserving a layer for a pose to override these default poses.

    Oops! Presumably not an issue, since it'll be updated correctly in the first Update call.

    I do want to set the animation clip as well, but maybe this is a better way to create the new layer?

    Hmmm. Yes, they're unchanged. I'm only setting the state weights. Since each layer has only one state, should I be setting layer weight instead?
     
  20. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Any way to create layers is fine, they're all the same internally. And while there are some differences between state weight and layer weight in some cases, I don't think they matter here.
     
  21. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    @Kybernetik
    I tried switching from setting state weights to layer weights and that actually made things worse: it would only show the gun pose with a very slight influence of some other pose.

    Then, just for the hell of it, I set both the layer and the state weights to the same value. That seems like something that really shouldn't work at all, but it actually worked correctly! (Well, mostly -- There's still an odd issue.) I would've expected setting a state to 0.5 and it's layer to 0.5 would have a net effect of 0.25.

    None of this seems to be working in a way that makes sense to me. I'm guessing that something I'm doing is a little unusual and revealing some edge case buggy behavior. I'll check this out again when v7 is ready -- or if you like, I could test with v7 before it's released and help track down the issue, if it still exists.
     
  22. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    That is very strange. Setting both weights to 0.5 should definitely result in an output of 0.25. Maybe there's something different about layer mixing that we don't really understand.

    Animancer v7.0 isn't likely to affect this issue in any way since I haven't made any changes to the layer or weight systems in a long time. If you can't figure it out, the best thing to do would probably be to create a minimal reproduction project and send it to animancer@kybernetik.com.au so I can take a look at it.

    I wasn't planning on doing a public test release of v7.0 since it takes a bunch of extra time to prepare and manage but I rarely get any useful feedback from it. But if you're really interested in trying it I wouldn't mind an excuse to get away from endlessly working on the documentation so just mention it in an email along with your Invoice Number so I can verify your purchase.
     
  23. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    The last bit of strange behavior I'm seeing now is that transitioning from one pose to another, at the mid point (ie, the two poses are at 0.5 weight) the result is neither pose, but the default pose of the hand. I'm guessing this is related to the fact that I'm setting both the layer and the state weights to the same value. So maybe at that midway point between the two poses, each of them is having a net effect of 25% and the remaining 50% is the default pose.
     
  24. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    Thanks again for sorting me out, @Kybernetik.

    Should anyone else encounter the same issues, the solution for me was to place all the states I was blending between on a single layer, rather than each state in its own layer. Layer blending behaves a little differently from state blending.
     
  25. seoyeon222222

    seoyeon222222

    Joined:
    Nov 18, 2020
    Posts:
    184
    upload_2021-7-23_2-22-25.png

    The following NullReferenceException error are not resolved during the Prefab / Prefab Variant works
    I removed all the components, and added it again
    But the error still occurs.

    Is this issue, which is scheduled to be resolved in 7.0 the same issue that I have?
    upload_2021-7-23_2-25-9.png
    Is there a simple temporary solution?
    (such as actions to avoid causing problems)

    In Change Log page,
    Planned Release 2021-07-?? means,
    It will be a release this month?
     
  26. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    If you have Animancer Pro you can use the solution I posted here.

    Otherwise, if you get the error, Right Click any script and reimport it to make Unity recompile and reload everything. The problem with the old implementation is that the AnimancerGUI class sometimes gets accessed before Unity has initialized the EditorStyles which causes the exception, and since it happened in the static constructor anything else that tries to access the class will re-throw the same exception until the assemblies are reloaded.

    Animancer v7.0 is essentially complete except for the documentation and final testing for Animancer itself as well as the Platformer Game Kit which I'll be releasing at the same time (and I still need to write the upgrader script for the Upgrade Process). There's still quite a bit of documentation left so I might not make it by the end of the month, but it shouldn't be too long after that. If you want to try it out early, you can send your Invoice Number to animancer@kybernetik.com.au and I'll send you a test version.
     
  27. kirbyderby2000

    kirbyderby2000

    Joined:
    Apr 28, 2017
    Posts:
    35
    Very nice asset! You have literally saved me from animator hell.

    I was having a really hard time modifying the script in the walkthrough "Example 7: Layers" to have the character continue an action animation in the proper layer and frame in the event that the action animation was being interrupted by switching between the running / walking animations. I finally got it to work but I don't know how my working code is different from what I was doing earlier; I can't seem to reproduce the issue where the weights weren't properly crossfading. I kept getting this warning in the inspector that weights weren't equal to 0 / 1 and the character was in a really wonky position and doing hilarious broken poses. In any case, if anyone wants perfect action animations maintained between layer transitions following Example 7: Layers, here's the script for beautiful transitions.


    Code (CSharp):
    1. using UnityEngine;
    2. using Animancer;
    3.  
    4. public sealed class LayerExample : MonoBehaviour
    5.     {
    6.         /************************************************************************************************************************/
    7.  
    8.         [SerializeField] private AnimancerComponent _BasicAnimancer;
    9.         [SerializeField] private AnimancerComponent _LayeredAnimancer;
    10.  
    11.         [SerializeField] private AnimationClip _Idle;
    12.         [SerializeField] private AnimationClip _Run;
    13.         [SerializeField] private AnimationClip _Action;
    14.  
    15.         [SerializeField] private AvatarMask _ActionMask;
    16.  
    17.         /************************************************************************************************************************/
    18.  
    19.         private const int BaseLayer = 0;
    20.         private const int ActionLayer = 1;
    21.         [SerializeField, Range(0.05f,1.0f)]
    22.         private float FadeDuration = 0.25f;
    23.  
    24.         /************************************************************************************************************************/
    25.  
    26.         private void OnEnable()
    27.         {
    28.             // Idle on default layer 0.
    29.             _BasicAnimancer.Play(_Idle);
    30.             _LayeredAnimancer.Play(_Idle);
    31.  
    32.             // Set the mask for layer 1 (this automatically creates the layer).
    33.             _LayeredAnimancer.Layers[ActionLayer].SetMask(_ActionMask);
    34.  
    35.             // Since we set a mask it will use the name of the mask in the Inspector by default. But we can also
    36.             // replace it with a custom name. Either way, layer names are only used in the Inspector and any calls to
    37.             // this method will be compiled out of runtime builds.
    38.             _LayeredAnimancer.Layers[ActionLayer].SetDebugName("Action Layer");
    39.         }
    40.  
    41.         /************************************************************************************************************************/
    42.  
    43.         private bool _IsRunning;
    44.  
    45.         public void ToggleRunning()
    46.         {
    47.             // Swap between true and false.
    48.             _IsRunning = !_IsRunning;
    49.  
    50.             // Determine which animation to play.
    51.             var animation = _IsRunning ? _Run : _Idle;
    52.  
    53.             // Play it.
    54.             _BasicAnimancer.Play(animation, FadeDuration);
    55.             _LayeredAnimancer.Play(animation, FadeDuration);
    56.  
    57.             // Check if the last action animation is still being played while changing running state,
    58.             // If yes then resume the animation at the proper frame in the proper layer
    59.             if(_lastActionPerformed != null)
    60.             {
    61.                 if (_lastActionPerformed.IsPlaying)
    62.                 {
    63.                     // Cache the time of the animation
    64.                     float timedFrame = _lastActionPerformed.Time;
    65.                     // Play the action animation in the proper layer and readjust the time
    66.                     // in the new animation
    67.                     if (_IsRunning)
    68.                     {
    69.                         _lastActionPerformed = _LayeredAnimancer.Layers[ActionLayer].Play(_Action, FadeDuration, FadeMode.FromStart);
    70.                         _lastActionPerformed.Time = timedFrame;
    71.                         _lastActionPerformed.Events.OnEnd = () => _LayeredAnimancer.Layers[ActionLayer].StartFade(0, FadeDuration);
    72.                     }
    73.                     else
    74.                     {
    75.                         _lastActionPerformed = _LayeredAnimancer.Layers[BaseLayer].Play(_Action, FadeDuration, FadeMode.FromStart);
    76.                         _lastActionPerformed.Time = timedFrame;
    77.                         _lastActionPerformed.Events.OnEnd = () => _LayeredAnimancer.Play(_Idle, FadeDuration);
    78.                     }
    79.                 }
    80.             }
    81.         }
    82.  
    83.         /************************************************************************************************************************/
    84.         // cache the last action animation state played
    85.         private AnimancerState _lastActionPerformed;
    86.  
    87.         public void PerformAction()
    88.         {
    89.             // Basic.
    90.             var state = _BasicAnimancer.Play(_Action, FadeDuration);
    91.             state.Events.OnEnd = () => _BasicAnimancer.Play(_IsRunning ? _Run : _Idle, FadeDuration);
    92.  
    93.             // Layered.
    94.  
    95.             // When running, perform the action on the ActionLayer (1) then fade that layer back out.
    96.             if (_IsRunning)
    97.             {
    98.                 _lastActionPerformed = _LayeredAnimancer.Layers[ActionLayer].Play(_Action, FadeDuration, FadeMode.FromStart);
    99.                 _lastActionPerformed.Events.OnEnd = () => _LayeredAnimancer.Layers[ActionLayer].StartFade(0, FadeDuration);
    100.             }
    101.             else// Otherwise perform the action on the BaseLayer (0) then return to idle.
    102.             {
    103.                 _lastActionPerformed = _LayeredAnimancer.Layers[BaseLayer].Play(_Action, FadeDuration, FadeMode.FromStart);
    104.                 _lastActionPerformed.Events.OnEnd = () => _LayeredAnimancer.Play(_Idle, FadeDuration);
    105.             }
    106.         }
    107.  
    108.         /************************************************************************************************************************/
    109.     }
     
    Kybernetik likes this.
  28. kirbyderby2000

    kirbyderby2000

    Joined:
    Apr 28, 2017
    Posts:
    35
    Amazing asset. Honestly this should be the way Unity animations work out of the box. So ridiculous that I'm making complex state machine in code and I have to essentially replicate the same state machine in Unity's restrictive animation controller system.


    Quick question, does the Transition Preview support previewing 2D directional mixers (MixerState.Transition2D) with a visual graph; the same way Unity's animation system lets you preview blend trees?

    Here's what I mean:

    Unity's 2D Directional Blend Tree inspector lets you preview an animation blend by dragging the red dot around in realtime:

    upload_2021-7-23_12-46-7.png


    I don't see anything like that in the Transition Preview window, or am I missing it?

    upload_2021-7-23_12-46-28.png
     
  29. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    If you scroll down and expand the mixer state (should be 2 lines below the bottom of that screenshot) you can modify its parameters.

    Adding an interface to drag around like Blend Trees is on my to do list, but it would take quite a bit of work to get right (especially if I try to figure out how they're generating that background texture) so I haven't been treating it as a high priority.
     
  30. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
  31. BlankMauser

    BlankMauser

    Joined:
    Dec 10, 2013
    Posts:
    138
    Hey so I'm using Animancer 6.0 in a networked environment where I'll need to step through animations in a very controlled fashion.

    How do I make it so that my animations play but don't actually "update" their animation? Instead, I only want to update the animation using the function AnimancerState.Evaluate(deltaTime);
     
  32. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    animancer.Playable.PauseGraph();

    The Update Rate example shows it in action.
     
    BlankMauser likes this.
  33. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    Is there a way to set the speed of the entire animator? I tried animancer.Playable.Speed, animancer.Animator.speed, and neither seems to work :(

    Note I am playing a animator controller through animancer
     
    Last edited: Aug 1, 2021
  34. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    animancer.Playable.Speed is the correct way for everything else, it just doesn't work for AnimatorControllerPlayables (they have a speed like all other playables, they just ignore it).

    The only way I know of is to give the Animator Controller a Float parameter and link the speed of all of its states to that parameter.
     
  35. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    Darn, I see. What if I wanted to pause the animation? I tried PauseGraph but it makes the character T-Pose.
     
  36. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Pausing the graph should work fine as long as you call Evaluate at least once to actually apply it to the model. Can you describe the problem in a bit more detail?
     
  37. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    After the character has animated a bit, I pause it via PauseGraph(). The transforms pause correctly (and thus attached meshes to said transforms pause correctly), but the skinned mesh itself does not, and instead reverts to its t-pose, ie default state. Just in case I tried running Evaluate beforehand, but figured that wouldn't matter since the transforms do indeed pause correctly.

    I also tried baking the skinned mesh, but it doesn't quite work... if I bake the mesh the same frame or the frame after I pause the animation, the animation gets paused one frame ahead of the baked mesh. If I try baking it 3 frames ahead, it bakes as a T-Pose.

    I then set the animancer's culling mode from "cull update transforms" to "always animate". This stopped the character from T-Posing, but instead seemed to pause the skinned mesh at its default state, as opposed to its current state and time.

    I think I'm going to give up on trying to pause animation. Unity's animation system is incredibly frustrating.
     
  38. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    The SkinnedMeshRenderer should be operating based on the Transforms only. It shouldn't know or care whether those Transforms are being controlled by an animation system or scripts or anything. Something strange must be going on.
     
  39. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Hey everyone, just thought I'd let you know that there's currently a Free Asset Giveaway on the Asset Store containing 3 animation packs. All you need to do is add those assets to your cart and put in ANIMATE2021 as the coupon code before paying. That's my affiliate link by the way, so if you do buy anything I get a small commission (which doesn't cost you anything extra).
     
  40. itadakiass

    itadakiass

    Joined:
    Nov 11, 2017
    Posts:
    21
    Hi, after updating to 7.0 I keep getting errors in vscode due to:
    Code (CSharp):
    1. Error: The primary reference "Animancer.Lite" could not be resolved because it was built against the ".NETFramework,Version=v4.7.2" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.7.1".
    Changing csproj files TargetFramework solves this, but these files are reverted every time I open the project. Do you possibly know how can I fix it?
     
  41. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Strange that I never encountered that while testing. Which Unity version are you using?

    Anyway, I've recompiled the Lite DLLs for Target Framework v4.7.1 so you can just download the attached zip and copy the DLLs for your Unity version over your existing ones.

    I'm working on a couple of minor bug fixes at the moment so I'll probably upload a new version to the store in the next few days.
     

    Attached Files:

    itadakiass likes this.
  42. cfusion

    cfusion

    Joined:
    Jul 18, 2011
    Posts:
    12
    I'm using the latest version of Animancer (7.0) and MixerTransition2D properties are not showing the list of animations in the editor. I have a custom component with nothing but a [SerializeField] private MixerTransition2D _mixer and all of the properties show except the list of animations. I also checked SpiderBotAdvanced and it's animation list is also not showing.
     
  43. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Are you getting any errors?

    Do you have Odin Inspector?

    Can you post a screenshot of what you're seeing?
     
  44. cfusion

    cfusion

    Joined:
    Jul 18, 2011
    Posts:
    12
    Yes, I am using the latest version of Odin inspector.

    No errors - but if I click on the Preview button I see the list of animations in the AdvancedSpiderBot script. I added an animation to my custom script and I get editor errors now when I go to the Transition Preview: a null reference on DirectionalMixterState.ForceRecalculateWeights(), line 86.

    Unity_2021-08-03_02-21-00.png
     
  45. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Try putting a [DrawWithUnity] attribute on the field to prevent Odin from screwing it up.

    Can you post the actual stack trace of the exception you're getting?
     
  46. cfusion

    cfusion

    Joined:
    Jul 18, 2011
    Posts:
    12
    The [DrawWithUnity] attribute fixed it. Thanks so much. I didn't have to use that attribute a month ago with previous versions of Animancer and Odin Inspector.

    The null reference only occurs when I go into the Transition Preview with an animation added. This only occurs on my custom component - the Spider Bot from the Examples folder is fine.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. Animancer.DirectionalMixerState.ForceRecalculateWeights () (at Assets/Plugins/Animancer/Internal/Mixer States/DirectionalMixerState.cs:86)
    3. Animancer.MixerState.RecalculateWeights () (at Assets/Plugins/Animancer/Internal/Mixer States/MixerState.cs:549)
    4. Animancer.MixerState.CreatePlayable (UnityEngine.Playables.Playable& playable) (at Assets/Plugins/Animancer/Internal/Mixer States/MixerState.cs:289)
    5. Animancer.AnimancerNode.CreatePlayable () (at Assets/Plugins/Animancer/Internal/Core/AnimancerNode.cs:64)
    6. Animancer.AnimancerState.CreatePlayable () (at Assets/Plugins/Animancer/Internal/Core/AnimancerState.cs:294)
    7. Animancer.AnimancerState.SetRoot (Animancer.AnimancerPlayable root) (at Assets/Plugins/Animancer/Internal/Core/AnimancerState.cs:74)
    8. Animancer.AnimancerPlayable+StateDictionary.GetOrCreate (Animancer.ITransition transition) (at Assets/Plugins/Animancer/Internal/Core/AnimancerPlayable.StateDictionary.cs:235)
    9. Animancer.Editor.TransitionPreviewWindow+Animations.DoCurrentAnimationGUI (Animancer.AnimancerPlayable animancer) (at Assets/Plugins/Animancer/Internal/Editor/Transition Preview Window/TransitionPreviewWindow.Animations.cs:317)
    10. Animancer.Editor.TransitionPreviewWindow+Animations.DoGUI () (at Assets/Plugins/Animancer/Internal/Editor/Transition Preview Window/TransitionPreviewWindow.Animations.cs:58)
    11. Animancer.Editor.TransitionPreviewWindow+Inspector.DoPreviewInspectorGUI () (at Assets/Plugins/Animancer/Internal/Editor/Transition Preview Window/TransitionPreviewWindow.Inspector.cs:79)
    12. Animancer.Editor.TransitionPreviewWindow+Inspector.OnInspectorGUI () (at Assets/Plugins/Animancer/Internal/Editor/Transition Preview Window/TransitionPreviewWindow.Inspector.cs:60)
    13. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <da82069731e64928932a97bb7b1b5945>:0)
    14. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    15.  
     
  47. itadakiass

    itadakiass

    Joined:
    Nov 11, 2017
    Posts:
    21
    I am using 2021.1.16f.
    Vscode package from the package manager has 4.7.1 version hardcoded in their project files generator script. I dont really know how all these NET framework stuff works, so I am not sure who is to blame here :) I heard that Rider package allows you to customize TargetFramework for generated projects right in unity settings. Unfortunatly with vscode you cant.

    Anyways, thank you for the hotfix! It works now :)
     
  48. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    @cfusion My understanding is that Odin searches through all available types to find the appropriate drawer class for a particular type, but there's a bug in the way they choose the correct one compared to the default way Unity decides so they end up picking the wrong one. In your case, I believe it picked the base TransitionDrawer which doesn't know how to draw the table of animations/thresholds/speeds/sync instead of choosing the ManualMixerTransition.Drawer where that stuff is actually handled. So I'd recommend letting them know about the issue since I don't have Odin Inspector myself.

    That exception looks like it would be caused if you only have one animation in the mixer which shouldn't generally be a problem since the whole point is to mix multiple animations. But I've fixed it for the next version.
     
    cfusion likes this.
  49. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    @Kybernetik is it ok to change a layer's properties during runtime? I am talking about SetMask and IsAdditive. I've tried changing IsAdditive and it seems to work. Is there any reason this would be a bad idea? I am trying to limit the amount of layers for each character as how I understand it each layer costs a bit of performance.
     
  50. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,568
    Layers are only created at runtime so you have to set their details at runtime. I don't know that I've ever specifically tried swapping a layer back and forth between additive/override or changing its mask repeatedly, but I see no reason why it shouldn't work. It would just be a trade-off between the immediate cost of setting the mask vs. the passive cost of an unused layer.
     
    JohnTomorrow likes this.