Search Unity

Animation: Starting, stopping reversing

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

  1. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    Hi,
    Is it possble to:

    1. Play an animation from any frame to any frame eg I keyframe some animation covering 60 frames, but I only want to play frames 23 to 34

    2. Play an animation backwards?

    many thanks,
    Richard.
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Currently there is no very easy way to do this.
    We will be working on improvements to the animation system for version 1.2.


    But for now you can use the SampleAnimation function.
    file:///Applications/Unity/Documentation/ScriptReference/GameObject.html#SampleAnimation

    This lets you sample any animation at any time. Thus inside the Update function you just call SampleAnimation with the time you want to sample.
    Code (csharp):
    1.  
    2. function Update ()
    3. {
    4.   gameObject.SampleAnimation (animation.clip, Time.time);
    5. }
    6.  
    This way you can also playback animations reverse or slowed down. Or however you want it.
     
  3. Richard_B

    Richard_B

    Joined:
    Jul 22, 2005
    Posts:
    436
    It will do the trick this time. Though I had looked at all methods with the word animation in them - but no :(

    thanks,
    Richard.