5

I am making an animation on enemy death but the animation doesnt end on an empty frame so the last frame of the animation will remain on the screen. I saw others complete it by making an empty keyframe as the last frame of the animation to make the animation disappear from the screen after the last frame, but i can't find a way to do it.

Wanted effect https://i.stack.imgur.com/eMOjr.jpg Finding the way to make the last empty keyframe

0

5 Answers 5

7

A year late, but I found your question while searching for a similar thing. Probably you have solved your issue by now. But seeing a question left misunderstood and unanswered bothers me. Anyway, I wanted to add here for others who may come here searching for this.

  • First Adding an extra key-frame at the end, initially with a sprite active.
  • Then activate "Key-frame Recording mode" (by pressing the red large dot) in animation window.
  • Be sure that the key-frame that you want empty is selected.
  • Go to your Inspector window. Find the Sprite Render Component. It should have a "Sprite" field at the top.
  • While "Key-frame Recording mode" active, you set this field to 'none' (by clicking the icon that has a circle with a dot, and selecting the first item in the popup).
  • Then disable the record mode.

Without activating record mode, this would revert back to the previous sprite.

Of course, as derHugo explained nicely, to make the animation stop at the last (now empty) frame, you also need to click on your animation file in project window and disable "Loop Time" in the inspector.

1
  • Additional clarification: For the "Key-frame Recording mode" button to be active the Animation window must not be maximized. You need to be able to see your Scene or Prefab window as well. When you are selecting the Sprite Renderer it is associated with the GameObject that your Animator is attached to. Very confusing. Apr 23 at 14:58
1

I don't think others manually add them since there is no such thing like an empty keyframe. Sometimes this simply happens e.g. when dealing with sprites see Why are there extra frames in Unity's Animation System?. I guess it has something to do with the execution order and rendering order of animators and UI stuff.

However, you could simply create an additional keyframe going to the wanted time and simply double click in the timeline to add a keyframe for all properties with the current state:

enter image description here

alternatively you can also select all properties for one keyframe by clicking on the keyframe in the grey bar and do CTRLc - CTRLv to copy the selected keyframes elsewhere.


so the last frame of the animation will remain on the screen

this is actually achieved by simply disabling

Loop Time

Enable to make the animation plays through and then restart when the end is reached.

of the according animation clip

enter image description here

1
  • the current effect, the last frame remaining on the screen after the animation ended
    – AOV Ezy
    May 23, 2019 at 13:09
1

I found the record method to be a bit cumbersome. What I do is add a Key to the first frame I want the None sprite to be set. The new Key I added was at time zero.

Image of adding Key to animation.

After saving the changes in the editor I open the .anim file (not the .anim.meta file) in a text editor and search for the relevant path. In my case Body/Cape.

- curve:
- time: 0
  value: {fileID: -6465775046297182995, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
- time: 0.05
  value: {fileID: -6465775046297182995, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
- time: 0.06666667
  value: {fileID: 3394640672729110067, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
- time: 0.083333336
  value: {fileID: -4514068313588038808, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
- time: 0.1
  value: {fileID: 7087822514200124772, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
attribute: m_Sprite
path: Body/Cape

And I replace the frame at the corresponding time (in my case time of 0) with the None file (fileID of 0):

- curve:
- time: 0
  value: {fileID: 0}
- time: 0.05
  value: {fileID: -6465775046297182995, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
- time: 0.06666667
  value: {fileID: 3394640672729110067, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
- time: 0.083333336
  value: {fileID: -4514068313588038808, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
- time: 0.1
  value: {fileID: 7087822514200124772, guid: fda466c51014e1140b1fd77abcc15ca3,
    type: 3}
attribute: m_Sprite
path: Body/Cape
0

Press the red record button in the Animation tab and disable the Sprite Renderer of your GameObject. Then stop recording by clicking the same button again. This way you animation will disable the sprite renderer and this way make the object invisible. After the end of the animation the Sprite Renderer will be reset automatically.

enter image description here

0

As described in a couple of the other answers, the UI is so clumsy it is ridiculous. You might have an easier time editing the YAML of the .anim file.

  • Add a keyframe at the end.
    It will re-use the last sprite.
  • Edit the YAML to set the fileID to 0 for that last keyframe
    (two new lines that have a fileID in the YAML)

This will clear the last sprite.

Here is a screenshot of what the diff should look like:

Diff showing '{fileID: 0}' on the 2 new lines with a fileID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.