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.

Animancer - Less Animator Controller, More Animator Control

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

  1. frostymm

    frostymm

    Joined:
    Jun 21, 2013
    Posts:
    34
    Hello again,

    Quick question, is there anything in this plugin that might help me get the position of a bone in a specific frame of an animation without actually playing it? I'm trying to do some predictive collision stuff but I need to know the position a bone will be 1 frame into the future. Currently I'm doing that by playing the animation on both my character and on a separate bone structure animated 1 frame ahead and with collisions disabled on it. It's pretty terrible.

    I figure I might be missing something so I should ask!
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    Unfortunately the Playables API doesn't give us access to anything like that. You might be able to improve performance a bit by giving the dummy an AvatarMask so it doesn't animate the bones you don't care about, but I don't know how much that might help (if any).
     
  3. frostymm

    frostymm

    Joined:
    Jun 21, 2013
    Posts:
    34
    Lol gotcha, I might give that a try. I haven't noticed any performance drops from it *yet* but I'm sure I'll eventually come across something to at least clean it up. Thanks for the quick reply!
     
  4. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Do you have a beginner video?

    You are using concepts in your tutorial that I am not familiar with, so I am struggling to add animations to my own script, by following your tutorial. Its nice to learn new concepts, however its a rabbit hole with regards to educating yourself on a limited amount of time.
     
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    The v4.0 documentation has a new C# in Unity section which explains a lot of basic programming concepts and I'm working on improving all the Examples as part of the update (this page tracks my progress). You can get the Beta from here.

    And if you have questions, you can always ask (here is fine, but if you create a Github Issue you get your own thread so it's easier to manage).
     
    Last edited: Jan 16, 2020
    nobluff67 and hopeful like this.
  6. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Thanks, going a bit better now.
     
  7. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, have you read this post?
    https://connect.unity.com/p/articles-animation-injection

    It's a very interesting technique to reduce clutter. However, it's written 3 years ago and I'm not sure if it is still applicable.

    If not, I think Animancer can easily support the Injection as you have full control. Is it possible that we add support for the animation-set and swap them out on the fly? If so, I think it will make Animancer very interesting Asset.

    Thanks.
     
  8. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    Animancer is already built around the concept of injection and is far easier to use than that. Your scripts can just play whatever Animation Clips they want. So your weapon script can just have an "AnimationClip[] attacks" and your attack script can call "animancer.Play(currentWeapon.attacks[0])" whenever it wants to without any other setup steps. If memory management is an issue you can always destroy the old states when you unequip a weapon.
     
  9. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hmm.. that's not exactly what I mean. I know that you can just play any animation clip but you will have to manage what to play depends on what weapons you hold.

    Instead, you will have the default set of animation and the inject will replace some animations from the default set and calling Play will be the same, e.g., animancer.Play(attacks[0]), in other words, no changes necessary for the calling code.
    That's what injection is. And injection will manage the memory for you as it can off load replaced animations, another bonus.
     
  10. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    I still don't see what you're actually asking for. Animancer lets you get animations from wherever you want, so if you want to have a default set of animations to use when a weapon doesn't have anything to replace them with, then you can just do that in your scripts. There is no way for the system to manage the memory for you without imposing restrictions on where the animations can come from, but destroying the states of an unequipped weapon is a trivial task which is easily worth it to avoid unnecessary restrictions.

    Can you give an example of something you're trying to do and how you think Animancer could make it easier?
     
  11. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    ok, here is a simple example

    Code (CSharp):
    1.  
    2.  
    3.   private Dictionary<string, AnimationClip> defaultAnimSet = new Dictionary<string, AnimationClip>();
    4.   private Dictionary<string, AnimationClip> rifleAnimSet = new Dictionary<string, AnimationClip>();
    5.  
    6. // first create default AnimSets
    7.   public void InitAnimSet()
    8.   {
    9.     defaultAnimSet.Add("idle", IdleAnimClip);
    10.     defaultAnimSet.Add("walk", IdleAnimClip);
    11.     defaultAnimSet.Add("run", IdleAnimClip);
    12.     ...
    13.     animancer.SetAnimSet(defaultAnimSet);
    14.   }
    15.  
    16. // create custom AnimSets
    17.   public void CreateRifleAnimSet()
    18.   {
    19.     rifleAnimSet.Add("idle", RifleIdleAnimClip);
    20.     rifleAnimSet.Add("walk", RifleIdleAnimClip);
    21.     ...
    22.   }
    23.  
    24. // replace the existing animation using the new AnimSet.
    25. // when previous animation is found, unload it.
    26.   public void InjectAnimSet(Dictionary<string, AnimationClip> rifleAnimSet)
    27.   {
    28.     animancer.SetAnimSet(rifleAnimSet);
    29.   }
    30.  
    31.   void Update()
    32.   {
    33. // Find the animation from the current AnimSet and play.
    34.     animancer.Play("idle");
    35.   }  
     
  12. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    I can see some value in a system like that, but it would take a lot of work to do properly:
    • If you're going to us a keyed system like that, I'd much rather encourage the use of enums instead of strings so it would at least need to be a generic class.
    • There's no reason to limit it to only a single fallback. You could have Fighting Style -> Weapon -> Class -> Race, etc. But I'm not sure how that could be properly generalised, especially if an Animation Set is a Scriptable Object asset which can be shared among multiple objects since you want to save memory (since each object could have a different fallback for the same set).
    • Using Transitions (renamed from Serializables in v4.0) would be better than direct Animation Clips so you can actually customise the details of each of them, but then each state is still limited to only having a single clip (assuming the whole point is to be able to serialize an animation set so you can set it up in the Inspector) rather than using Mixers, Animator Controllers, or Timeline Assets.
    • Using Transition Assets would allow you to use Mixers and all the rest, but then you need to create separate assets for each of them which is annoying if you do just want to use single clips for everything, and I would have to choose one or the other when writing the system.
    It definitely won't make it into v4.0, but I'll put it on my list of ideas to consider for the next major version.
     
    Willbkool_FPCS likes this.
  13. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Right now, I'm still trying to figure out what advantages I'll be having Animancer over traditional Mechanim. I like Animancer because you have finer control but it requires a lot more work to type things and it's not easy to visualize the whole setup. So in my opinion, Animancer should promote the user without the need for visualization as much as possible unless you will create your own visualization tools. I think Swapping AnimationSet depends on the weapon, race, and stuff will definitely help make the code less complicated. Of course, Animancer requires more work to make it easier for the users to use and I don't mean to undermine the efforts.

    To help the sales, I think you will need to make it clear what are the benefits and be honest about the disadvantages and how you plan to overcome them. This is where most of the people who will be wondering if it worths it or not.

    So, I was thinking having a clear advantage will help make the decision. Animation Injection is just one of them. Animation Injection in Mechanim is very difficult to do and without it, a complicated animation will run out of control easily. I hope Animancer can take advantage of the situation.
    Thanks.
     
  14. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
  15. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    There really shouldn't be anything wrong with that because there aren't any ints in that example. Can you post your whole script?
     
  16. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    338
    Cant even find it now as I have moved to the next section of your tutorial, so have overwritten code that was giving me issue. I have tried to recreate it however I now run into another error. Here is the code, its a copy and paste from the link:

    Its now giving me an error on the States bit of code.

    The description of the error is:

    Assets\IdleAndWalk.cs(25,24): error CS1061: 'AnimancerComponent' does not contain a definition for 'States' and no accessible extension method 'States' accepting a first argument of type 'AnimancerComponent' could be found (are you missing a using directive or an assembly reference?)

    _Animancer.States.Current.Speed = movement;

    Code (CSharp):
    1. sing Animancer;
    2. using UnityEngine;
    3.  
    4. public class IdleAndWalk : MonoBehaviour
    5. {
    6.     [SerializeField]
    7.     private AnimancerComponent _Animancer;
    8.     public AnimancerComponent Animancer { get { return _Animancer; } }
    9.  
    10.     [SerializeField]
    11.     private AnimationClip _Idle;
    12.     public AnimationClip Idle { get { return _Idle; } }
    13.  
    14.     [SerializeField]
    15.     private AnimationClip _Walk;
    16.     public AnimationClip Walk { get { return _Walk; } }
    17.  
    18.     protected void Update()
    19.     {
    20.         var movement = Input.GetAxisRaw("Vertical");
    21.         if (movement != 0)
    22.         {
    23.             PlayMove();
    24.  
    25.             _Animancer.States.Current.Speed = movement;
    26.         }
    27.         else
    28.         {
    29.             _Animancer.Play(_Idle, 0.25f);
    30.         }
    31.     }
    32.  
    33.     protected virtual void PlayMove()
    34.     {
    35.         _Animancer.Play(_Walk, 0.25f);
    36.     }
    37.  
    38.     protected virtual void Reset()
    39.     {
    40.         AnimancerUtilities.IfMultiComponentThenChangeType(this);
    41.     }
    42. }
     
  17. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    nobluff67 likes this.
  18. nobluff

    nobluff

    Joined:
    Jan 17, 2016
    Posts:
    1
    I am looking for your thoughts on compatibility with PuppetMaster. This is the view from the creator:

    Thanks.
     
    hopeful likes this.
  19. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    I haven't used PuppetMaster before, but that sounds like an accurate summary.
     
    nobluff67 likes this.
  20. trnq1ll0

    trnq1ll0

    Joined:
    Aug 30, 2019
    Posts:
    42
    Thanks for this plugin, I tried it today because I'm struggling with the Unity playing graph. But I also have a problem with Animancer. I want to chain several animations and play them one after the other. I have solved this with the following script, but I get an error and don't know why:
    NullReferenceException: Object reference not set to an instance of an object
    ...runAnimationList (System.Collections.Generic.List`1[T] Animations) (at ScritptableAsset.cs:355)


    Code (CSharp):
    1.     private void runAnimationList(List<AnimationClip> Animations)
    2.     {
    3.         Animancer.AnimancerState[] state = new Animancer.AnimancerState[Animations.Count];
    4.         state[0] = _Animancer.Play(Animations[0]);
    5.         for(int i=1; i < Animations.Count; i++)
    6.         {
    7.             state[i-1].OnEnd = () => _Animancer.Play(Animations[i]);  <== [I]NullReferenceException[/I]
    8.         }
    9.     }
    PS: *bing* Now I know why the error appears, because only state[0] is filled. But when I try to fix it with
    state[i-1].OnEnd = () => state[i] = _Animancer.Play(Animations[i]);
    I also get the error and the animation chain is broken.
     
  21. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    That's a simple logic error, here's what it's doing:
    1. Play animations[0] and store it in state[0].
    2. Set state[0].OnEnd.
    3. Set state[1].OnEnd, but state[1] doesn't exist yet. It will only be created when states[0] ends.
    Try something like this:
    Code (CSharp):
    1. private void runAnimationList(List<AnimationClip> Animations)
    2. {
    3.     var state = _Animancer.Play(Animations[0]);
    4.     var index = 0;
    5.  
    6.     System.Action onEnd = null;
    7.     onEnd = () =>
    8.     {
    9.         index++;
    10.         if (index >= Animations.Count)
    11.             return;
    12.  
    13.         state = _Animancer.Play(Animations[index]);
    14.         state.OnEnd = onEnd;
    15.     }
    16.  
    17.     state.OnEnd = onEnd;
    18. }
     
    trnq1ll0 likes this.
  22. trnq1ll0

    trnq1ll0

    Joined:
    Aug 30, 2019
    Posts:
    42
    This is great. Thank you! And i love the CrossFade(). :)
     
  23. vice39

    vice39

    Joined:
    Nov 11, 2016
    Posts:
    108
    Is there a way to pause an animation? I want it to stop playing, but not go rewind to start.
     
  24. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    To pause a single animation:
    Code (CSharp):
    1. var state = animancer.Play(clip);
    2. // Or "var state = animancer.GetState(clip);" to get an existing state.
    3. // Or if you are using the v4.0 Beta it would be "var state = animancer.States[clip];"
    4. state.IsPlaying = false;
    5. state.Speed = 0;// Same effect, but slightly worse for performance.
    Or to pause all animations:
    Code (CSharp):
    1. animancer.Playable.PauseGraph();
    2. animancer.Playable.Speed = 0;// Same effect, but slightly worse for performance.
     
  25. trnq1ll0

    trnq1ll0

    Joined:
    Aug 30, 2019
    Posts:
    42
    I can't use Animancer together with a unity AudioSource.
    If:
    Code (CSharp):
    1. _Animancer.CrossFade(animationClip);
    2. audioSource.Play();
    The animation plays but not so the audio clip.

    And If:
    Code (CSharp):
    1. audioSource.Play();
    2. _Animancer.CrossFade(animationClip);
    The audio plays but not the animation clip.

    edit: i'am in Unity 2019.3 0f3
     
  26. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    I just tested it to make sure and it worked fine (2019.3.0f1). You are probably doing something else wrong because there is nothing in Animancer that has anything to do with audio (except the Animation Events examples which are able to play sounds normally). It is theoretically possible that it's a bug in the Playables API since it does have audio stuff too, but Animancer doesn't use any of that so I doubt it.

    If you can put together a minimal reproduction project containing only that script, animation, and sound, then I'll happily take a look at it but it seems extremely unlikely that this would be an actual bug.
     
    Last edited: Jan 27, 2020
  27. trnq1ll0

    trnq1ll0

    Joined:
    Aug 30, 2019
    Posts:
    42
    Thanks for your answer. Unfortunately it is a very large and complex project, but I will try to reduce it to a reproducible minimum. Maybe I'll find the error already there.
     
  28. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    Hey everyone, Animancer v4.0 is now available on the Asset Store ([Lite] and [Pro]). Here are some of the highlights:
    • The main public API has been entirely restructured. In particular, the Play, CrossFade, CrossFadeFromStart, and Transition methods are all now called Play with fewer overall parameter combinations, but the changes are far more extensive than that.
    • [Pro-Only] New Animancer Event system for general events without needing to use Unity's Animation Events and the ability to set custom end times.
    • New Transition Preview Window allows you to preview your transitions on your character without entering Play Mode.
    • [Pro-Only] Implemented Mixer Time Synchronisation.
    • Added Weapons example as well as instructions for downloading animations from Mixamo and configure their Import settings.
    • Added a C# in Unity section to explain the fundamentals of programming in Unity.
    • I'm now using Github Issues for questions/bugs/etc. as an alternative to everyone spamming each other in this thread.
    See the Change Log for the full list of changes and remember to always delete any older version of Animancer before upgrading.

    If you don't yet have Animancer Pro, check out the Reddit Thread for a chance to win a free voucher.
     
    Last edited: Jan 29, 2020
  29. spacefrog

    spacefrog

    Joined:
    Jun 14, 2009
    Posts:
    732
    Thanks Kybernetik for your wonderful plugin
    Just upgraded to V4 and everything went smooth after i made the few API related code adaptions.
    I use Animancer for spritebased animation control and may only scratch the surface of whats even possible., but in general i'm totally happy that i went the Animancer approach instead of using Mecanim (which of course i considered too at the beginning ). The latter certainly would already have caused me getting roasted in Animator controller state hell ( We are talking about at least 2000 individual sprite animationclips here ... )
    I certainly will use Animancer for future projects too
     
    Last edited: Jan 31, 2020
    Kybernetik likes this.
  30. trnq1ll0

    trnq1ll0

    Joined:
    Aug 30, 2019
    Posts:
    42
    After reseting all animations and sounds, the project worked fine. I have absolutly no clue what the problem was before, but there is nothing to do for you. :)
     
  31. craigjwhitmore

    craigjwhitmore

    Joined:
    Apr 15, 2018
    Posts:
    135
    If Carlsberg made animation frameworks....

    Great update, thank you for all the hard work.
     
    Kybernetik likes this.
  32. vice39

    vice39

    Joined:
    Nov 11, 2016
    Posts:
    108
    Is it possible to get an callback or event when a specific animation ends ?
     
  33. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
  34. dead_pixel_society

    dead_pixel_society

    Joined:
    Oct 1, 2013
    Posts:
    8
    Loving Animancer Lite, great work Kybernetik...I will be looking to purchase Pro in the coming weeks.

    I do have a couple of questions. These are mostly just me getting my head around the workflow, (and I think it's probably related to something touched upon in chrisk's earlier post)

    In the included Weapons Example, switching the weapon only defines the actual attack animations, but I also would also like to be able to override the Idle, Walk and Run Mixer based on the held weapon.
    For the sake of example, to a Mixer that is also weapon-based, like; Idle_SwordHeld, Walk_SwordHeld, Run_SwordHeld or Idle_Rifle, Walk_Rifle, Run_Rifle.

    I can imagine this to be quite straightforward to set mixers in the current weapon script and apply them in a similar way to the attack animations, I haven't had time yet to try.

    However, I'm also interested in approaching Animancer from a 'scriptableobject based statemachine' system that could be defined by swapping, overriding, or layering, scriptableobject animation sets/mixers.

    In the included examples, the main demonstrations of the animation state machine is a child gameobject to the character, with multiple anim-state monbehaviour scripts attached that have their references set up in the inspector.
    One of the few benefits I currently see with Mechanim is that a standard controller asset, once defined, could simply be assigned to many animators with the same locomotion intent, and I'm keen to know if there is a recommended best practice to approach Animancer in a similar, asset-based, way?

    I am aware of the directional sprites example, which I assume is the best representation of this kind of idea (as you mention in your docs).

    So, as another example, the main 'locomotion set' would include the Idle_normal, Walk_normal and Run_normal. An alternative set for 'Crouch' would include: Idle_Crouch, Walk_Crouch, Run_Crouch or another for let say, a drunk state: Idle_Drunk, Walk_Drunk, (Run_Drunk? :)), that could over-ride or even perhaps layer with avatar-masks over the main animation locomotion set.

    I hope that was clear, and would appreciate any thoughts or recommendations on approaching this. Hopefully im not muddling things.
     
    Last edited: Feb 10, 2020
  35. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    I've reordered the parts I'm quoting a bit.

    Yeah, that should be pretty simple. The only reason I didn't put Idle/Walk/Run overrides in the Weapons example is so that it could reuse the existing scripts from earlier examples. If not for that, it would be easy to have those scripts simply check if the equipped weapon has an animation before falling back to the unarmed animations.

    You could probably set up a layering system something like this (just written here so obviously I haven't tested it):

    Code (CSharp):
    1. public sealed class CharacterAnimationSet : ScriptableObject
    2. {
    3.     [SerializeField]
    4.     private AnimationClip _Idle;
    5.     public AnimationClip Idle { get { return _Idle; } }
    6.     // Or use a ClipState.Transition to define the fade duration and stuff with it.
    7.  
    8.     // Other animations.
    9. }
    10.  
    11. AnimancerComponent _Animancer;
    12. List<CharacterAnimationSet> _Animations;
    13.  
    14. public AnimationClip GetAnimation(Func<CharacterAnimationSet, AnimationClip> getClip)
    15. {
    16.     for (int i = _Animations.Count - 1; i >= 0; i--)
    17.     {
    18.         var clip = getClip(_Animations[i]);
    19.         if (clip != null)
    20.             return clip;
    21.     }
    22.  
    23.     return null;
    24. }
    25.  
    26. public void PlayIdleAnimation()
    27. {
    28.     var clip = GetAnimation((set) => set.Idle);
    29.     if (clip != null)
    30.         _Animancer.Play(clip);
    31. }
    Or instead of using delegates you could put a dictionary in CharacterAnimationSet to let animations be retrieved with some key (probably an enum).

    It's entirely up to you how you want to structure things. For example, you could make a prefab which only has your state machine scripts attached so you can instantiate it for any creatures and connect it to their respective models and CharacterAnimationSets at runtime.

    Or instead of having CharacterAnimationSet as a ScriptableObject, it could be a MonoBehaviour so you can attach the default animations of a model to the model itself. So you have one prefab defining the structure of your state machine and another prefab with the model and animations it will use.
     
    dead_pixel_society likes this.
  36. dead_pixel_society

    dead_pixel_society

    Joined:
    Oct 1, 2013
    Posts:
    8
    thanks so much for your amazingly swift and detailed reply and example!
     
  37. Chebn

    Chebn

    Joined:
    Oct 25, 2019
    Posts:
    8
    Do you have any example where you move the Base layer animation to the Action layer but keep the animation timing the same? So if the player triggered an attack and midway through the attack they start running, it should just transition the animation to the Action layer (without starting from the beginning) and be able to perform the Base layer running animation. If they stop running afterwards, it should transition the Action layer back to the base layer and continue the animation as well.
     
  38. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    I've never tried something like that but it should be possible.

    Simply setting the state.Layer or LayerIndex would work if you don't need a smooth transition.

    Otherwise you would need to do something like this:
    Code (CSharp):
    1. public void ToggleRunning()
    2. {
    3.     // Toggle _IsRunning and play the walk or run animation.
    4.  
    5.     var oldState = _Animancer.States[_Action];
    6.     if (oldState != null && oldState.Weight != 0)
    7.     {
    8.         var layer = _Animancer.Layers[_IsRunning ? ActionLayer : BaseLayer];
    9.         var newState = layer.Play(_Action, FadeDuration, FadeMode.FromStart);
    10.         newState.Time = oldState.Time;
    11.      
    12.         if (_IsRunning)
    13.         {
    14.             newState.Events.OnEnd = () => _LayeredAnimancer.Layers[ActionLayer].StartFade(0, FadeDuration);
    15.         }
    16.         else
    17.         {
    18.             _Animancer.Layers[ActionLayer].StartFade(0, FadeDuration);
    19.             state.Events.OnEnd = () => _LayeredAnimancer.Play(_Idle, FadeDuration);
    20.         }
    21.     }
    22. }
     
  39. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    I have an existing Mechanim animation controller and I've come to a spot where I need to adjust the weights and playback speeds for individual clips within a 2D Freeform Cartesian blend tree dynamically at runtime. I have found no way to do this w/Mechanim, and I ran across Animancer in the process. Is it possible to use Animancer to modify these values for an exsiting mechanim controller? If so, is there any references on how to do so? I checked out https://kybernetik.com.au/animancer/api/Animancer/HybridAnimancerComponent/ , and it looks like that should allow me to use Animancer in some capacity to play an existing animation controller, but does it provide access to everything in the animator?

    Thanks for any info!
     
  40. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    Playing an Animator Controller in Animancer only lets you control it normally, it doesn't give you any additional access to the internals.

    But if you use a Cartesian Mixer State instead, then you would have full access to all its internal weights and speeds.
     
    Lipoly likes this.
  41. Lipoly

    Lipoly

    Joined:
    Feb 11, 2014
    Posts:
    42
    Thanks for the reply. I'm assuming it isn't possible/practical to use the Animancer Cartesian Mixer State with an existing Mechanim controller?
     
  42. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    The Hybrid Basics example demonstrates how you can use separate animations alongside an Animator Controller so you can blend between it and the mixer as necessary, but the mixer cannot be inside the Animator Controller itself.
     
    Lipoly likes this.
  43. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    This asset doesnt play well with puppetmaster. The way puppetmaster works is it is manually enabling and disabling the animator component. At various times during puppetmasters update cycle it is calling
    targetAnimator.enabled = true;
    and
    targetAnimator.enabled = false;
    it is also manually updating the animator
     targetAnimator.Update(deltaTime);


    Im wondering what would be the best way to integrate the two. Is there a way to stop animancer from updating the animator and allow puppetmaster to push the updates? Or maybe a way to edit puppetmaster to point at animancer rather than the animator? What would be an animancer equivilent to a manual update or disabling the animator?
     
    Last edited: Feb 16, 2020
  44. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    You can't directly control the Animator like that when using the Playables API, but if you can modify Puppetmaster then you should be able to do what you want with:
    Code (CSharp):
    1. AnimancerComponent animancer;
    2. animancer.Playable.PauseGraph();
    3. animancer.Playable.UnpauseGraph();
    4. animancer.Evaluate(deltaTime);
    Also, how did you format the code in your post like that? I didn't think this forum supported inline code.
     
  45. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    Thanks that worked. It took a bit of jumping around puppetmaster to reconnect things and Ill still have to go through and manually set the blending weights to point to animancer instead of directly blending in the animator component, but the important part I wanted was the secondary physics to work alongside animancer. By changing the
    targetAnimator 
    to an AnimancerComponent instead of an Animator and changing
    targetAnimator.enabled
    to pause/unpause as well as changing Update to Evaluate I was able to get it working.

    Its called
    inline code
    , its the button next to the code block. can also just type [ + ICODE + ] and [+/ICODE+] without the +'s

    upload_2020-2-15_15-56-49.png
     
    Last edited: Feb 16, 2020
    Kybernetik, hopeful and StevenPicard like this.
  46. caste

    caste

    Joined:
    Dec 19, 2012
    Posts:
    9
    I have question - How to imlement ThirdPersonUserControl.cs and ThirdPersonCharacter.cs to animancer. It's used more than 10 animations states for each rotation and u can exit in any time to walk ,when u release the button. In each yours examples i found no more than 4 states for animation.In Directional Blending examples u don't rotate animated robot. Just blend by states and direct by mouse. Other exampleas combine standart animation controller with animancer ,looks stuped. Please gime me code sample (
     
  47. caste

    caste

    Joined:
    Dec 19, 2012
    Posts:
    9
    I have question - How to imlement ThirdPersonUserControl.cs and ThirdPersonCharacter.cs to animancer. It's used more than 10 animations states for each rotation and u can exit in any time to walk ,when u release the button. In each yours examples i found no more than 4 states for animation.In Directional Blending examples u don't rotate animated robot. Just blend by states and direct by mouse. Other exampleas combine standart animation controller with animancer ,looks stuped. Please gime me code sample (
     
  48. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    The examples already are code samples and the Documentation explains how they work in great detail so that you can figure out how to use Animancer in any situation you might encounter.

    If you are trying to convert an Animator Controller based system to use Animancer instead then I suggest you look at the 3D Game Kit example because that's exactly what it demonstrates.
     
  49. caste

    caste

    Joined:
    Dec 19, 2012
    Posts:
    9
    Look . I have directions vector . And it's send as parameters to ITransition
    statates. But if its goal the state i need to switch to _walk state and play _walk until new key pressed ( direction changes). How to do it?
     
    Last edited: Feb 18, 2020
  50. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,501
    I'm not really sure what you're asking. If you tell it to play a walk animation then it will keep playing that animation until you tell it to play something else. The Brains example demonstrates how you can implement movement based on keyboard controls if that helps.
     
    slimshader likes this.