Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animation window showing different result than the Game view

Discussion in 'Animation' started by DroidifyDevs, Jul 25, 2017.

  1. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    Hello!

    I edited a run animation I downloaded to give it a more "bouncy" feel. I'M not great at animating, but it seems to look OK when I run the animation via the animator window. Problem is, when I play the animation in-game via a character controller, the result is completely different. It looks as if I never edited the animation.

    Here's what I mean:


    In the video, you see that I play the game and the original animation plays. Then I play my edited version in the Animator window. The orc bounces as I want him to, but this animation does NOT show in game.

    Did I miss something?

    Thanks!
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Not sure if editing a pre-created animation works in Unity, but confess I have not tried.
    Can you edit it externally instead? That will work.
     
  3. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    By editing externally, do you mean 3rd party software like 3DS?

    Also, do you mean you can't edit animations in Unity with the Animation window? That seems strange if you can make animations from scratch but can't edit preexisting animations.
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    My apologies DD I think I incorrectly assumed this was an imported fbx animation rather than an .anim created in Unity.
    Please disregard my previous as we are talking about different animation types.

    The only thing I can think of is possibly the old animation is named the same as the new animation - and the old animation is currently in the state machine?
     
  5. SoxwareInteractive

    SoxwareInteractive

    Joined:
    Jan 31, 2015
    Posts:
    541
    Hi @DroidifyDevs,

    Does the animation work in the preview window?
    Click on the .anim file in the project window --> a preview window will appear in the bottom of the inspector window.
    If it displays a wrong character, drag and drop the correct character into the preview window.
    Click on the "Play"-Button (in the Preview Window) and check if your animation is working as expected.

    If you want, I can take a closer look if you upload a unity package with your animation and the character.
     
  6. SoxwareInteractive

    SoxwareInteractive

    Joined:
    Jan 31, 2015
    Posts:
    541
    I just had an idea of what might cause your issue.

    The only thing you are not seeing are the changes applied to the GameObject's global position correct? This is because changes to the global position are applied by "Root Motion". When the curve for the global position was created by hand, you need to ensure that beside the position curve there is also an Animator.Motion T (generic) or Animator.Root T (humanoid) curve. Those curves are used by the "Root Motion" system during runtime to change the global position of the character. I found no way on how to add those Curves in the Unity Animation Window though (maybe I have overseen something).

    But luckily, in your case you can do a workaround:
    Apply your y-position changes not to the root of the GameObject, but to the transform that is often called "Reference" or "Root":
    upload_2017-7-26_7-34-52.png

    That way, "Root Motion" is not involved and everything should work as expected.
     
  7. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    Thanks for the replies!

    I'm very sorry I'm late on mine, I was on an unexpected (but amazing) trip to Canada.

    No, that appears to be the original animation. The only place I can get the new one to work is in the Animation window.

    I think yes, I made that animation days ago, but I did change the positon to make a "hopping" effect, and also sped it up a bit to make the animation faster. But as you see, there's no "root":


    Here's the model and animation: https://1drv.ms/u/s!Ao-fan5pgktlhOsRFulfa2enaO5xTA

    However, I think the only thing you'll see is the old animation, as the Animation window doesn't seem to be applying changes to my .anim file.
     
  8. SoxwareInteractive

    SoxwareInteractive

    Joined:
    Jan 31, 2015
    Posts:
    541
    Sorry I had no time too look into the package you sent yet.

    I just remembered that there is actually a way to create the Motion.T and Motion.Q curves in Unity. You need to select the *.anim file and in the inspector you should see a button called "Generate Root Motion Curves". This will create the Motion.T and Motion.Q curves for you. That should fix your problem.

    upload_2017-7-31_8-1-20.png



    And the transform that was called "Root" in my case is named "Bip001" in your case. It is the transform that is parent of all bones and a child of the GameObjects root.
     
  9. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    I tried the button "Generate Root Motion Curves", and it did start moving the transform arrows in the Preview window. However, in-game, the character wasn't moving.

    So, I decided to go ahead and use Bip001 to change its position. However, I can't seem to change Bip001's position. After about half an hour of aimlessly trying to set keyframes that automatically reset themselves to their old values, I noticed this error:
    upload_2017-8-1_18-2-29.png
    So how do I convert OrcWalk3 to a Humanoid clip? Also, the button "Generate Root Motion Curves" seems to have disappeared... :(


    This shows I'm not good at animation.
     
  10. SoxwareInteractive

    SoxwareInteractive

    Joined:
    Jan 31, 2015
    Posts:
    541
    As you've already noticed due to the fact that your character is "humanoid" you aren't really able to create keys for the transforms and bones of your model through the animation window as "humanoid" animations are using "muscles" instead. I have somehow overseen that you have a humanoid animation clip, I'm sorry.

    Check out the Animator.RootT curve at the very end of your animation. Select it and click on "Curves". Then modify the key values to your need. This curve is the root motion curve of humanoid characters and will change the position of the whole character.

    The other way would be to change your character rig to "generic" (when you click on the model in the project window) which allows you to animate any bone from the animation window. But then you loose the ability of retargeting, meaning that you can't use your run animation from the Asset Store anymore.
     
    DroidifyDevs likes this.
  11. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    This is an imported clip from 3D Max - tell tale sign - bip00x.
    I refer back to original suggestion - can't this be updated externally - in blender or other?

    And these links -
    https://forum.unity3d.com/threads/m...g-creation-of-animations.465466/#post-3029036
    https://forum.unity3d.com/threads/m...ic-animation-not-working.463290/#post-3010360

    @DroidifyDevs if you can't solve by the end of the week - I can help - free of charge. This can be solved very quickly externally.
    PM me if you want.
     
    DroidifyDevs likes this.
  12. DroidifyDevs

    DroidifyDevs

    Joined:
    Jun 24, 2015
    Posts:
    1,724
    THIS. That lets me edit the model's position. I did not realize there were such large differences between Humanoid and Generic animations.

    I guess I have 1 more question:
    upload_2017-8-2_23-19-3.png
    Is there a way to change the animation's length, apart from adding more keyframes? Currently, it's 0.24 seconds long, but I think it would be easier to manage if it was a simpler number, such as 0.2. Is there a way to select all the keyframes and "spread them out"?

    Huge thanks as that solved my issue; I can now add some bounce to this animation, and I didn't have to take up @theANMATOR2b 's very generous offer.

    I'm sure it can be edited externally, I just don't have Blender installed and am generally not good at drawing, modeling, animating etc... but I'm trying to learn what I can to progress my knowledge and project, even if I'm not good at it.

    You wrote something interesting:
    Does this mean that humanoid animations can't be converted to generic? Can generic animations be converted to humanoid? Because in the past, I've ran into many issues where certain animations wouldn't work on certain characters, and I think this is why.

    Here's proof that it works:

    Obviously it's exaggerated and I'll tone it down, but I think the bounce gives more liveliness to my very unfinished game that looks like a rip-off of the Survival Shooter tutorial.
     
    Last edited: Aug 3, 2017
    theANMATOR2b likes this.
  13. SoxwareInteractive

    SoxwareInteractive

    Joined:
    Jan 31, 2015
    Posts:
    541
    Cool, nice to see that it works now!

    Scaling the animation does work in >= Unity 5.5:


    When you have a .fbx file with animations attached, you can change it from humanoid to generic in the import settings (you see them in the inspector when you select the .fbx file in the project window). But if it is generic, that animation can only be used by the model with exactly the same bone hierarchy and bone proportions specified in the .fbx file.
     
    theANMATOR2b and DroidifyDevs like this.