Search Unity

Animation: Framebased to Time based

Discussion in 'Editor & General Support' started by Richard_B, Jul 31, 2005.

  1. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    I am just trying to figure out how Unity converts keyframed animations to time based. If I set the framerate to say, 15fps and then keyframe based on that frame rate, does Unity automatically play it back so that, say, a key set at frame 30 will play two seconds after the animation was started?

    thanks,
    Richard.
     
  2. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    This is a bit OT for Unity - but does anyone know how to rename the animation clips that Unity imports from Maya?

    thanks,
    Richard.
     
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You can either rename in maya. Using create animation clip.

    Or do it in unity by naming the file you want to import like this:

    monster@walk.fbx
    monster@run.fbx

    Unity's animation system is time based not frame based.
     
  4. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    I couldn't get this to work. I created an animation clip (which was easy to rename). I also checked the objects animation was using the clip (by changing some of the keys). The clip was called "doorHingeGCh" but in Unity it still appeared to be called "Take 001".

    I could easily rename AnimationClips that were created in Unity, but I couldn't rename the Maya ones - I guess that makes sense.

    Anyhow, this is only a minor issue - just trying to grips with Unity's animation system.

    thanks,
    Richard.
     
  5. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Seems the maya name not getting across correctly was a bug in unity.
    Fix will be in the next 1.1 beta.
     
  6. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    Great!

    thanks,
    Richard.
     
  7. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Not sure if i was clear with the renaming of maya animation clips.
    You have to name the file you want to import differently.
    In your case you probably use maya so you would name your file like this:
    monster@walk.mb

    This will automatically rename all animation clips to "walk" when importing.
     
  8. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    OK - tried this and it certainly works - thanks. So at the moment if I want to create different named animation clips with Maya I have to do it with different files ie. at the moment only one, different-named-clip per .mb file?

    cheers,
    Richard.

    PS I should add that if I animate different transform Locators then in Unity I do see one animation per Locator however, they all have the same name.
     
  9. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    Another thing (sorry to be a bother). If I create a cylinder in Unity and add an Animation component to it, then drag the Maya created AnimationClip on to the cylinders animation clip field in the inspector, the cylinder does follow the animation (the Animation is set to "Play Automatically") . The clip is just a rotation about the y-axis and does work on the Maya object. From this I deduce that AnimationClips aren't really independent, but, at least for Maya animations, are tied to the Maya object?

    many thanks,
    Richard.
     
  10. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Not sure what you are doing different but if i:
    1) Create a cube in maya and animate it
    2) Create a cylinder in unity
    3) drag the animation clip of the mb file onto the cylinder in the scene view
    4) Hit play. It will play back the animation on the cylinder.

    This feature is normally referred to as animation remapping. I presume that is what you mean by independent.

    If this is not how it is behaving on your machine, then it is a bug.
     
  11. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    Ok - if I repeat your steps all works well - thanks!

    However, the original clip I created still didn't work. I think I know what the problem is: If the keyframing is done done to an object which is not the root of the hierarchy (in Maya) then the clip doesn't play when remapped. I tested this on a very simple scene - I'll file a bug report shortly.

    In case other users are interested, this was part of the door opening test scene. http://otee.dk/forum/viewtopic.php?t=334. Clicking on the doorhandle opens and closes the door. Thinking of this as a two state machine here is a simple script that switches animations with each click on the object:

    Code (csharp):
    1.  using UnityEngine;
    2. using System.Collections;
    3.  
    4. //*************************************************
    5. public class switchStates : MonoBehaviour {
    6. //*************************************************
    7.  
    8. public AnimationClip firstClip, secondClip;  
    9.  
    10. private  int currentState;
    11. private  enum state : int {
    12.     FIRST,
    13.     SECOND,  
    14. }  
    15.  
    16.  
    17. //--------------------------------------------------
    18. void Awake () {
    19. //--------------------------------------------------
    20.           currentState = (int) state.FIRST;
    21. }
    22.    
    23.  
    24. //--------------------------------------------------
    25.  void OnMouseDown () {
    26. //--------------------------------------------------
    27.  
    28.     switch(currentState){
    29.        
    30.         case (int) state.FIRST:
    31.             animation.clip =  firstClip;
    32.             animation.Play ();
    33.             currentState = (int) state.SECOND;
    34.         break;
    35.         case (int) state.SECOND:
    36.               animation.clip =  secondClip;
    37.               animation.Play ();
    38.               currentState = (int) state.FIRST;
    39.         break;
    40.     }    
    41.          
    42.  
    43. }
    44.    
    45. }  
    46.  
    thanks again,
    Richard.
     
  12. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Yes thats true. If you have a hierarchy which is animated it will look up the children which it wants to animate by name.

    You can also use the "Animation Stored in Nodes" setting, in the mesh import settings. This will create one clip for every animated node.
    This way you can assign any of the animation clips to any other object in your scene, no matter their name.