Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Animancer - Less Animator Controller, More Animator Control

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

  1. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    284
    Will do thanks, I'm curious about this, if this can be resolved it will be more flexible to do things.
     
  2. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    I have a character I'm thinking of animating in the scene using the Timeline. What I want is for that character to follow the animation I set in the Timeline, but for the upper body to dynamically respond to being hit by the player. While PlayableDirector is animating, it seems to completely take over from the Animator Controller -- my hope is that Animancer's support for Timeline playback would allow me to play with layers at the same time. Would that work?
     
  3. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    You should be able to play a Timeline on the base layer and do whatever you want on other layers same as you would while playing a regular animation on the base layer. It might not work because Timeline wasn't written with the ability to play it alongside other stuff in mind so there's a lot of random stuff that just doesn't work properly. In this case I'd say it's likely to work, but you won't know until you try it.
     
  4. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    I've set up a Timeline for the base animation, and an Animator with a separate layer for the hit reactions -- so, no Animancer just yet. As anticipated, the PlayableDirector completely takes over, not allowing the Animator to blend layers.

    Next step, I'd like to try using Animancer's PlayableAssetState to replace the PlayableDirector, in combination with the HybridAnimancerComponent. I'm not quite clear how to set that up, though. Is there an example somewhere?
     
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    A HybridAnimancerComponent will play the Animator Controller on the base layer by default so you're probably better off using a Controller Transition directly. Once you've got a ControllerTransition and PlayableAssetTransition, playing them each on a different layer works the same as with individual clips as demonstrated in the Layers Examples.
     
  6. Barliesque

    Barliesque

    Joined:
    Jan 12, 2014
    Posts:
    128
    Okay, before I can get to making the layers thing work, I'm having an issue getting the timeline to play correctly. I have two tracks on the timeline: one to play full-body animations, the other to animate the position/rotation of the character in the scene. The animations are playing, but the character's position/rotation is not affected. Hopefully this isn't something that's unsupported...?
     
  7. inkofthedragon

    inkofthedragon

    Joined:
    May 10, 2023
    Posts:
    3
    I'm still trying to get footsteps sounds to work but no luck. The Debug never fires. I've tried the SetCallback method and the Unity Events method but nothing fires. Although if I use either of those methods for a weapon swing then it always works. It's only when walking/running. I don't understand what's the difference and where I'm preventing this from working.

    Code (CSharp):
    1. public class PlayerAnimationHandler : MonoBehaviour {
    2.  
    3. [SerializeField] private ClipTransition _walk;
    4.  
    5. private void Awake() {
    6.      _walk.Events.SetCallback("Step", FootStep);
    7. }
    8.  
    9. private void Update() {
    10.      HandleLocomotion();
    11. }
    12.  
    13. private void HandleLocomotion() {
    14.      ClipTransition moveAnim = null;
    15.      moveAnim = _parameters.CanRun
    16.           ? _run
    17.           : _walk;
    18.       PlayBase(moveAnim, false, AnimationType.Movement);
    19. }
    20.  
    21. public void FootStep() {
    22.      Debug.Log("Footstep");
    23. }
     
  8. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    @Barliesque Unfortunately, that's likely not supported. The second track would probably try to steal control away from Animancer.

    @inkofthedragon That script looks fine (assuming the _run field is similar to _walk) so there must be something else interfering with it. Do you have any other scripts playing animations? It might also help you narrow down the issue if you Right Click on the walk state in the AnimancerComponent Inspector to check if the events are currently assigned.
     
  9. inkofthedragon

    inkofthedragon

    Joined:
    May 10, 2023
    Posts:
    3
    Hi, I just emailed you a simple footsteps prototype. Could you look at it to see what I'm missing. Thanks!
     
  10. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
  11. inkofthedragon

    inkofthedragon

    Joined:
    May 10, 2023
    Posts:
    3
  12. asqewfcq2egf

    asqewfcq2egf

    Joined:
    Nov 16, 2018
    Posts:
    15
    I'm having an odd issue where i play an anim and a few bones don't seem to update properly, slowly drifting out of position, but when i either A: destroy the State for that anim via the context menu in the inspector, or B: change any property of the Animator from the inspector (such as update mode, apply root motion, culling mode ), then play the anim again (exact same params and everything), it suddenly works flawlessly. Very confused, any ideas?
     
  13. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    how to improve the performance of clips inspector in large project?
     
  14. LeifStro

    LeifStro

    Joined:
    Mar 23, 2015
    Posts:
    29
    Hey @Kybernetik, I just bought Animancer and started integrating it into my project. I have run into an issue, Animancer doesn't play animations on a character when the PuppetMaster plugin is being used with the Animator - 'Update Mode' set to 'Animate Physics'. If I change the Animator - 'Update Mode' to 'Normal', then it will play the animation, however this is not preferred as it causes jitter. Any idea/suggestion on how to get it to work with 'Animate Physics'?


    Here is a video of what recording a puppet master (using Unity Recorder) looks like when Animator - Update Mode: 'Normal'.


    Here is with Animator - Update Mode: 'Animate Physics':
     
    Last edited: May 11, 2023
  15. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    @asqewfcq2egf I've never seen anything like that. If you can send a minimal reproduction project to animancer@kybernetik.com.au I'd be happy to take a look at it.

    @ununion If you Right Click on a state or layer in the Inspector, there are a few Display Options to tweak. Enabling "Hide Inactive States" and disabling "Repaint Constantly" would both improve performance.

    @LeifStro Animancer should work in Animate Physics mode as long as you have the Animator set to that mode before Animancer is initialized (because Unity doesn't let it change modes). Which version of Unity are you using? Recent versions have actually deprecated the method Animancer uses to support Animate Physics and I'm hoping they haven't removed it completely because there is no alternative. When I reported it as a bug, the Unity developers tried to tell me that Animate Physics isn't supported on Playables at all, which means they forgot they even had that feature.
     
  16. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    Hey everyone, I just got a question about using 2D directional sprites in a 3D world so I made a new example which demonstrates how to do it. Feel free to check it out, and I plan on adding it to the next release of Animancer.
    DirectionRotation.gif
     
    iNSiPiD1 likes this.
  17. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    hi Kybernetik
    what will happen if I call several clip in one frame's update?for example like this
    Code (CSharp):
    1. void Update(){
    2.    ac.Play(clip1);
    3.    ac.Play(clip2);
    4. }
    Do I need to do some thing like record the call info,and only play the last one in late update?like this
    Code (CSharp):
    1. ClipTransition cp;
    2. void Play(cp){
    3.     this.cp=cp;
    4. }
    5. void LateUpdate(){
    6.     if(this.cp!=null){
    7.         ac.Play(this.cp);
    8.     }
    9. }
     
  18. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    Unlike Animator Controllers, Animancer will behave as you would expect, ending up playing clip2 just like if you had set x = 2 then x - 3 it would end up as 3.
     
  19. LeifStro

    LeifStro

    Joined:
    Mar 23, 2015
    Posts:
    29
    @Kybernetik thanks for the fast response. I am using Unity version 2021.3.1f1. However, I think that the issue is in the RootMotion - PuppetMaster plugin. I've found that when the Animator - Update Mode = 'Animate Physics', then PuppetMaster will run this code (attached image) in the FixedUpdate() function. As you can see, the way PupperMaster updates the Animator is by disabling it, and then calling the Animator.Update(float deltaTime) function, the Animator gets re-enabled (enabled = true) afterward in the Update() function. I think that its this disabling and re-enabling that is messing up the Animancer functionality.

    Is there a specific way we are supposed to manually update the Animancer component in this situation?
     

    Attached Files:

  20. semaforo

    semaforo

    Joined:
    Jun 25, 2017
    Posts:
    6
    Hey, relatively new user of Animancer here. I've been using it for the last few months, and its been pretty useful. Congrats on the tool!
    I'm currently working on a game that is pretty detailed with its animations systems (lots of blending, procedural/FinalIK stuff, and many many animation layers), and Animancer has been handling it all like a champ, also pretty easy to use.
    That being said, there's a few things that I feel are "basic" things that I may be missing, and decided to come here after being a little lost in the documentaion (which, for the most part, is pretty good as well).

    The biggest thing I don't quite understand is how Animancer handles transitions and how customizable that is. Let's say I have a Falling animation and an Idle animation. I want the transition from falling to idle to be instant when the player lands, but if the player is coming off an attack or interaction, I want the transition back to Idle to have a relatively long blend.
    As far as I understand, the transition that Animancer allows me to set in a Clip Transition is for the fade-in and not the fade-out, so my current solution is to have a third Clip Transition in between the fall and the idle that is just the idle animation with a 0s fade-in timer. That in turn becomes a clunky solution, because sometimes I'll want to cancel a fall into a run, so that's a 4th Clip Transition, and so on and so forth. Is there not a simple solution, where I can tell the falling clip to always immediately fade-out into whatever animation is coming next?

    As an extension of this question, is it possible to set an animation strictly as a blend animation? Say, if I have an AttackA to Attack B transition, can I set up a ClipTransitionC that automatically plays between them? Or does that need to be a separate animation call?
     
  21. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    @LeifStro The Update Rate Example explains how to manually update Animancer. Basically, call animancerComponent.Playable.PauseGraph() then animancerComponent.Evaluate(deltaTime).

    @semaforo When you call Play you can specify a custom fadeDuration even when using a Transition so you wouldn't need a whole new Transition for each combination, but your understanding is basically correct, Animancer doesn't currently have a clean way of handling that sort of thing other than requiring you to do it yourself. The How to implement transition sets post explains a general idea for solving the issue, but I'm still not sure what to do about the problems mentioned so I haven't started work on that feature yet.

    I'm not really sure what you mean by your last question, but a ClipTransitionSequence may be what you're looking for. Though I usually have a custom transition type for attacks with info about damage/hit boxes/etc. and only want to attack again if the player pressed the button again like in the Weapons Example so automatically playing the next animation wouldn't be desirable in that case.
     
  22. semaforo

    semaforo

    Joined:
    Jun 25, 2017
    Posts:
    6
    I see. The transition sets idea sounds perfect for this situation. Having an easier way of handling complex transition scenarios (such as the transition back to an idle animation, which is rarely just as simple as blending back into idle) would be amazing. I wonder if I could make a simple system like that myself. Just check which clip is playing and set up a fade or even a ClipTransition to play before the character goes back to idle. Is there an easy and performant way of getting and comparing ClipTransitions?

    The second question was a bit abstract, yeah. Basically, with Animator Controllers, it would be the equivalent of adding a new animation node between two animations, that has no conditions for transition and has Exit Time. I suppose that's the equivalent of a ClipTransitionSequence, I just always imagine there should be a faster way of dealing with transitions. Reading the transition sets idea sounds like it would fit here too, actually. Hopefully you do manage to solve the issues on that front, eventually.
     
  23. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    Animancer doesn't keep track of your transitions at all, it only interacts with them when you play one so any "getting and comparing" would be entirely up to however you want to store them. Such a system shouldn't need to access any internal Animancer stuff so there shouldn't be anything stopping you from trying it yourself (except time obviously) and I'd be keen to see what you come up with in case you come up with solutions for those issues I'm anticipating.

    Is the only purpose of that empty node to group transitions so you don't need to duplicate them all over the place? If so, that's something I definitely plan on including in my system. I'm thinking it would be some sort of fallback system where you can specify an exact X->Y combination as well as things like GroupZ->Y or AnythingElse->Y and it will just pick the highest priority transition for a given combination.
     
  24. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,491
    What do you think the most performant/practical approach to adding "lean" to a character would be? I have a character sitting on a vehicle and would like to lean to the left and right as the vehicle sways or turns.

    I'm pretty sure it would just be a masked layer that adds the bend to the appropriate spine bones. I thought of having one animation which sways from fully leftward at time 0, to fully rightward at time 1, and then setting the "time" position accordingly. I thought of having two animations that are just single frozen frames, and using two separate layers with weights, only one of which would be weighed in at a time. I thought of having different states and trying to manage the transition from different angles.
     
  25. semaforo

    semaforo

    Joined:
    Jun 25, 2017
    Posts:
    6
    Yeah, I tried looking at the documentation and figured Animancer wouldn't keep track of it. I'll try to come up with my own solution, though I'm more of an animator than I am a programmer, so I'll see where that leads me.

    Either way, yeah, you got the gist of the second one, hopefully that solution does come along, it would be good help, though either way I can manage without it for now.

    And thanks for the help! Animancer has been an amazing tool so far.
     
  26. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    @halley If it gives the result you want, I'd definitely go with an animation job like the Lean Example, which should have good performance and be easiest to implement. Otherwise, the 0-1 animation idea would probably give the next best performance as well as more control over the exact curves and poses. It should be possible to set that up as an additive animation so it's only adding rotation values to the bones you want it to lean rather than overriding your other animations.
     
  27. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,491
    Oh, I forgot about AnimationJobs, need to read up on it, see if it integrates well. But yeah, after watching a couple motorcycle videos I will probably want to fine-tune so the spine bends right but the head/neck bends left to compensate.
     
  28. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    I have an issue sampling an animation clip at runtime.

    My goal is to make the model be "frozen" in some specified pose that i sample from an animation clip for that model, at runtime.

    This is the script of the state. When i enter Idle state, i want it to sample the animation at a certain point and be frozen in that pose.

    Code (CSharp):
    1. public sealed class WaveIdleState : WaveState
    2.     {
    3.         public override StateType State => StateType.Idle;
    4.  
    5.         [SerializeField, Seconds(Rule = Validate.Value.ZeroToOne)]
    6.         private float _sampleNormalizedTime = 0f;
    7.         public float SampleNormalizedTime
    8.         {
    9.             get => _sampleNormalizedTime;
    10.             private set => _sampleNormalizedTime = Mathf.Clamp01(value);
    11.         }
    12.  
    13.         [SerializeField]
    14.         private AnimationClip _animationClip;
    15.         public AnimationClip AnimationClip
    16.         {
    17.             get => _animationClip;
    18.             private set => _animationClip = value;
    19.         }
    20.  
    21.         /// <inheritdoc />
    22.         public override void OnEnterState()
    23.         {
    24.             base.OnEnterState();
    25.             Animancer.Stop();
    26.             var sampleTime = SampleNormalizedTime * this.AnimationClip.length;
    27.             this.AnimationClip.SampleAnimation(this.Animancer.gameObject, sampleTime);
    28.         }
    29.  
    30.     }
    It doesn't seem to work. Structurally, the animancer component is on a parent GO of the animator component gameobject. I tried giving the gameobject from animancer and animator, there was no reaction to both cases.

    I looked into the sample extension method for editor, it does this similarly, so i assumed this is how i should do it, but no luck.
     
  29. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    The editor method is for sampling outside the regular animation system, it doesn't even initialize Animancer. You want something more like this:
    Code (CSharp):
    1. var state = Animancer.Play(AnimationClip);
    2. state.NormalizedTime = SampleNormalizedTime;
    3. Animancer.Playable.PauseGraph();
    4. Animancer.Evaluate();// This samples it immediately. Try without it first in case the regular update still happens this frame.
    And don't forget to Animancer.Playable.UnpauseGraph(); when exiting the state.
     
    iSinner likes this.
  30. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    Thanks, this achieves what i want. But i found a bug(i think) while investigating this, i will report it on github.
     
  31. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    What is the best way to synchronize 2 different animations, which are supposed to be looking as if it is one?

    For example i have an animation for a hoverboard, and for a character. And the character is supposed to be riding the hoverboard, but these are 2 separate objects with 2 separate animators.

    The character and the hoverboard have 3 different animations each, which represent phases of a single sequence.
    The character ascends on the hoverboard(pahse 1), rides it for some time(phase 2) and then descends it(phase 3).

    It goes 1 >2>>3 in sequence and should look like one seamless animation.

    The main "driving animation" is the character, i tried starting the hoverboard at the same time as the character, and assigning the speed and the normalized time of the animancer states to be the same on the hoverboard as it is on the character, the animation lengths(clips) are the same. And i do this each time i change the phase. But this approach yields not perfect results, i have some weird snaps when changing phases.

    Is this expected to happen? I am not sure if this is expected to happen or not, it feels like this shouldn't happen, but i don't know the internal details that could desync 2 animations that were started and synced at the start after which left to run on their own separately.

    And i tried a second approach, the main "driving animation" is still the character, as for the hoverboard, i don't let the time progress automatically, i just set the normalized time in the current state of the hoverboard's animancer to be equal to the normalized time of current state of the character's animancer(both on the same phase), and i have a perfect result, it looks as if the entire thing is one animation.

    I would like a suggestion on how should i approach these kind of scenarios, what is the best approach? maybe there are other options?
     
    Last edited: May 13, 2023
  32. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    With the first approach, how far is it off if you compare their times in the Inspector? If it's just a frame, it's because of a stupid design decision in the Playables API. If you set the time of an animation, it will stay at that time after the next animation update, meaning it's now one frame behind the main animation. If you can play and sync the animations in an Update method (i.e. before the animation update for that frame) then you could just add the current frame's delta time to the synced animation, but otherwise you would need the next frame's delta time which obviously doesn't exist yet so using the current delta would be close but not perfect (this would be the case if you're using events because they only trigger during the animation update).

    The second approach is a bit of an unfortunate hack, but it would get the job done fine.
     
    iSinner likes this.
  33. ncorns

    ncorns

    Joined:
    Jan 15, 2017
    Posts:
    10
    Hi - I've been using your asset for a while, it works great and even have it working over a network perfectly. I've managed to figure out a lot using the existing documentation and examples but unfortunately not having the same amount of luck with foot IK which im hoping you can point me in the right direction.

    My current setup is an animancercomponent. Animation clips are played at runtime via scriptable objects purely from code only. I also don't have a controller on the animator as have no need for one, so this is blank. I'm trying to use an AnimatedFloat to track the curves on each animation clip but unfortunately this line is giving me an exception

    _FootWeights = new AnimatedFloat(_animancer, "LeftFootIK", "RightFootIK");

    InvalidOperationException: The PropertyStreamHandle cannot be resolved.
    UnityEngine.Animations.PropertyStreamHandle.CheckIsValidAndResolve (UnityEngine.Animations.AnimationStream& stream) (at <d4133d02309b4839805ff06ac3f8d211>:0)


    The animations are imported as part of a model and i added custom curves via import settings - animation tab - curves as per the documentation. The curves are called LeftFootIK and RightFootIK. When then viewing the animations in the animation editor, i can see the curves exist for them and the spellings are correct as well.

    The documentation refers to adding float parameters to the controller but with using the AnimancerComponent, i dont use/need one. I tried using the hybrid component instead with float parameters and a controller but the outcome was the same.

    Any help appreciated.
     
  34. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    The only reason I've seen that error is if the curve name is wrong so check for spaces and capitalization.
     
  35. ncorns

    ncorns

    Joined:
    Jan 15, 2017
    Posts:
    10
    Thanks for the quick response, the spelling is correct . I've attached a screenshot of the component, the curves on the animation, the code and the animation timeline to demonstrate.I understand the animation timeline automatically adds spaces in which can be ignored.
     

    Attached Files:

  36. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    Yeah, that all looks fine so I'm not sure what's wrong.

    If you can strip it down to a minimal reproduction project with just your character, animation, and script and send it to animancer@kybernetik.com.au, I'll be happy to take a look at it.
     
  37. ncorns

    ncorns

    Joined:
    Jan 15, 2017
    Posts:
    10
    Thanks, appreciated. The only difference i can see between mine and the example is that im using the animancer component, not the named animancer component so i have no animations pre-added to the component like the example does. Maybe there is a problem when initialising that theres no animation clips for it to go through so it cant find the property references.
     
  38. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    It is more than a frame. I suppose its something on my part.
    I do start them at the same time, and then set the normalized time to 0 to both, and i debugged it and saw them starting at the same time.

    I also through code saw that the transition from `Phase 1` to `Phase 2` also happens at the same normalized time, but in the inspector it doesn't look so. In the inspector it looks like the "Main" object that starts the animation process and is driving the secondary object, looks like it transitions first, while the second looks like its normalized time doesn't reach the end. I am not sure if this is a problem with inspector representation only, or not.

    I would like to ask you about another thing though.

    I have 2 questions:

    1. If i pause the animancer state created from a playable asset transition(timeline), and set the normalized time of the animancer state, it doesn't update the pose of what the timeline is animating. Is this normal? I have to keep it playing in order to see the pose being updated, i can't pause it and just set the normalized time to whatever i need and obtain the pose at that normalized time, it just doesn't update the pose if it is paused.

    2. I have 3 phase animation, just like the last time i explained, but instead of animation clips i am using timelines, so i use playable asset transitions for them. I set the bindings in the transitions like this

    And this is how all 3 timelines look

    The first track animates the mesh, the second track animates a material property (which is on the "Wave_mesh_00" object)

    The first time the animancer is creating the states, it is animating both tracks just fine. The states are played in this order
    Start -> Middle -> End, and in all 3 playable asset transitions, it works just fine. The "Animation Track" is animating the mesh, and the "Animation Track (1)" is animating a parameter from the material of "Wave_mesh_00".

    After the End state ends, the root object is disabled and put in the pool, so the animancer component invokes the "Action on disable - Stop"

    The next time i play these animation, the object is taken from pool, the animancer states are already created from the previous time, and when the Start and Middle states play, they only animate the mesh which is bound to "Animation Track", and they do NOT animate the material parameter which is animated by "Animation Track (1)". Only the End state animates the material parameter, Start and Middle do NOT animate it, even though they should.

    The first time the animancer states are created, they are created in the order of Start, at the end of start Middle is created, at the end of middle End is created. And it looks like when the next time the animation is plalyed form the Start state, the binding for the "Wave_mesh_00" from the End state is the one that actually remains functional, while the rest are not for some reason(even though they all bind the same object "Wave_mesh_00"). So what i get, is that any subsequent calls to play the playable asset transitions after the first one, do not animate the property on the material for the object binding "Wave_mesh_00".

    When i set the "Action on disable - Destroy", each time the object is disabled(returned to pool), animancer destroys the animancer states, so the next time i take the object from pool, enable it and play the animation, the animancer states are created again in the order described above, as if for the first time, and this is how i avoid this issue. But to me it looks like a bug.

    The question is, is it really a bug, or am i missing something?
     
  39. LeifStro

    LeifStro

    Joined:
    Mar 23, 2015
    Posts:
    29
    @Kybernetik your suggestion was exactly what I needed, thank you.
     
    hopeful likes this.
  40. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    I can't think of anything else which could cause that. Can you send a minimal reproduction project to animancer@kybernetik.com.au so I can take a look at it?
    Timeline tracks are weird and outside of Animancer's control, but try setting the state's Speed to 0 instead of pausing it.
    It's probably by design for Timeline, but there might be something Animancer can do about it so if you can send me a minimal reproduction project for that too, I'll see if I can figure anything out.
     
  41. iSinner

    iSinner

    Joined:
    Dec 5, 2013
    Posts:
    201
    It actually worked. Thank you.
    Once i have time to do this, i will gather a re.pro. and send it(btw where to send, here or via github?).
    ATM i don't really have the time unfortunately and will be riding on the workaround i found :/
     
  42. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    Send the repro project to the email address I mentioned in my previous comment.
     
    iSinner likes this.
  43. ununion

    ununion

    Joined:
    Dec 2, 2018
    Posts:
    275
    Hi Kybernetik.
    A question about events,in my game that we can not use your event system or unity event system,the reason is complex and not important so I won't explain here.
    and here is our event implemention with animancer component,
    Code (CSharp):
    1.  
    2. //example event normalized time
    3. float eventTime   =0.5f;
    4. int triggerEventFrame=-1;
    5. private void Update() {
    6.  if (playingAnimancerState_.NormalizedTime > eventTime && Time.frameCount != triggerEventFrame) {
    7.   //trigger event
    8.   OnEvent();
    9.   trigerEventFrame = Time.frameCount;
    10.   }
    11. }
    So i want to know is there any problem or perfomance problem implement by this way?
     
    Last edited: May 18, 2023
  44. Ryirs

    Ryirs

    Joined:
    Jan 9, 2015
    Posts:
    12
    Hello, sorry if this was answered on an other page here.
    I am new to Animancer Pro and i an trying to setup a character and it's states.

    I went through all the examples but didn't find any matching the case i'm looking for (directional 2d with two speeds), they do some aspects in different examples but not int a single one so i am having trouble patching them together, they were either linear between two animations speed (walk and run), or directional 2d with only one speed (walk or run).

    I have assets with a set of animations for locomotion:
    -4x rotates in place (90 L/R, 180 L/R)
    -walk, 6 directions (front, front L/R, back, back L/R)
    -run, 3 directions, (front, front L/R, and stop)

    I am trying to understand what is the best approach to drive them.

    Do you do two "MixerTransition2D" (walk and run) and drive them nested in a "LinearMixerTransition" ?
    The spiderbot in example "03 Locomotion/03 Directional Blending" was uwing a "MixerTransition2D", but there is only one animation per direction.

    Or do you nest "LinearMixerTransition" where needed in the directions of a "MixerTransition2D"?

    Or is there a completely different approach ?

    The "3d Game Kit" example uses a quick turn animations (in place) otherwise it is just a LinearMixerTransition between walk and run, there is no walk and run turn animation, and the transform seems to be rotated.

    What would be the right approach/convention in this case ?

    Is there any example that uses root motion rotation with walk and run that i missed or didn't read properly ?

    Or should i just ignore the extra animations i was provided ?

    Thanks.
     
  45. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    I've never worked with complex animations like that so it may take some experimenting, but I'd start with something like this:

    For Movement:
    • Linear Mixer - parameter is speed (walk/run)
      • Directional Mixer - walk animations - parameter is 2D direction
      • Directional Mixer - run animations - parameter is 2D direction
    For Turning:
    • If you're just picking a single angle to turn like in the 3D Game Kit Example, just play them as individual animations.
    • Or if you want to pick an arbitrary angle between them, use a Linear Mixer with the angle as the parameter.
     
    Ryirs likes this.
  46. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    @ununion You're unlikely to see any performance problems from that approach. Getting Unity to call Update methods does have a significantly larger cost than a regular method call within C#, but in most cases it's still irrelevantly small.
     
  47. Ryirs

    Ryirs

    Joined:
    Jan 9, 2015
    Posts:
    12
    Hello, i have been playing with the when i found time the past two days, but i can't seem to get it where i want.

    First of all, is here the right place for support queries ?

    I was looking at the following page: https://kybernetik.com.au/animancer/docs/manual/blending/mixers/creation/
    specifically at the "transition nesting" and "manual nesting" sections, however i have issues with both (likely i am doing something wrong).

    The first example "transition nesting", seems to not display the two child "MixerState<Vector2>" as the inspector expect animation clip and doesn't display the mixer2d.

    The second example "manual nesting" displays the two serialized "MixerTransition2D", but not the parent "LinearMixerState".

    Is there a scene in the examples that uses nesting that i could look at ?
    thanks.
     
  48. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,580
    Here is fine for support, though I prefer Github Issues because having a separate thread for each topic makes things much easier to manage.

    In the Transition Nesting example, the MixerStates aren't shown in the Inspector because they aren't serialized fields (and can't be because states are only created at runtime and can't be serialized). The idea is that you create a Transition Asset for each of the 2D mixers then assign them to the _MovementMixer field in the Inspector (in the same slots where you would normally put AnimationClips).

    And in Manual Nesting the child 2D mixers are defined in the Inspector and the script creates the parent mixer state at runtime.

    The main reason there aren't examples for that is because I don't have any viable animations that could demonstrate anything useful with the concept, but I've added a diagram showing how all the parts fit together.
     
  49. Ryirs

    Ryirs

    Joined:
    Jan 9, 2015
    Posts:
    12
    Hello @Kybernetik, i think i am making good progress.

    I did encounter and issue though, one of the animation in my set seems to have been mirrored, so it doesn't blend correctly, the "cycle offset" value set on the animation clip does not seem to be used in Animancer, or am i missing something ?

    My animation has 24frames, but i would like it to start at 12, and loop from 12 to 11 (12-24-0-11), i expected the "cycle offset" on the animation to do that, but i don't see any difference when changing it so i suspect animancer always starts at 0.
    (the Start and End time in the ClipTransition is for cropping only right ?)
    Since it was mirrored from the opposite side, the position of the feet are inverted and when blending, they are canceling each other.

    Any suggestion ?
    Thanks.
     
  50. FairyMental

    FairyMental

    Joined:
    Apr 26, 2016
    Posts:
    5
    Hello,

    Trying to fix a little issue we have in our project. Uploaded a demo video of the problem on youtube:


    I've copied the state machine from a demo example, and used our custom animations. On the left side, the character uses an animator controller, the other uses a brain state machine from one of the demos. You can probably tell that one takes off and that probably should not happen. Any ideas why? Thank you.