Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

[RELEASED] Spritedow Animator, a simple sprite animation system

Discussion in 'Assets and Asset Store' started by Elendow, Apr 6, 2017.

  1. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi again,

    Yes, you are totally true, OnStop is fired when the animation is forced to stop someway, using the Stop method, when it stops when you use the method "StopAtFrame" or if it finished naturally when non looped. Sorry I didn't think of it early.

    As for the last request, I've added on the last update an AnimationDuration to the SpriteAnimation. This will give you the total frames of the animation (including the duration of the frames). Knowing this and the FPS of the animation you can calculate the frame corresponding to the half of the animation and the duration in seconds if you like.
     
  2. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Thanks. But how would I set the sprite animator to be on exactly half way playing entire animation duration in seconds? In order to do this I will need to be able to set the frame ( which of course I can ) and need to be able to set the internal time tick so that it is set precisely , not just beginning of the frame.
     
  3. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there,

    The new update 1.0.6 is live and ready to update. This is the changelog:

    - Added AdaptPivot to the UiImageAnimator
    - Added AnimationDuration to the SpriteAnimation
    - Added PlayStartingAtFrame without animation specified
    - Added PlayStartingAtFrame with SpriteAnimation as a parameter
    - Added AddCustomEvent with SpriteAnimation as a parameter
    - Added AddCustomEventAtEnd without animation specified
    - Added AddCustomEventAtEnd with SpriteAnimation as a parameter
    - Added GetCustomEvent with SpriteAnimation as a parameter
    - Added GetCustomEventAtEnd without animation specified
    - Added GetCustomEventAtEnd with SpriteAnimation as a parameter
    - Added PlayingAnimation proprety that returns the SpriteAnimation currently playing
    - Improved documentation

    As for your last recuest @castor76 i'm going to look at it and see what I can do, I'll probably add a method to set the internal time to whatever you like, hope this helps you.

    Cheers!
     
    Nikita500 likes this.
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Yeah sounds good!
     
  5. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there,

    The update 1.1.0 is now live, this is the changelog:

    - Fixed a bug with the times of the frames. Now your animations will play FASTER than before, because they were playing SLOWER than desired.
    - Fixed a bug with animations with empty frames on a UI Animator.
    - Added PlayStartingAtTime methods (without parameter, with animation name and with animation) to play your animation starting at the time (in seconds) desired.
    - Added SetAnimationTime method to set the animation's to the time (in seconds) you want.
    - Added UseAnimatorFPS method to override the animation's FPS.
    - Added UseAnimationFPS method to go back and use the animation FPS.
    - Added CurrentFrameRate property to get the current frame rate used by the animator.
    - Added CurrentAnimationTime property to get the current animation time in seconds.
     
  6. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Hi. How can I get the animation's duration in seconds?

    Also can we please get the Duration (frame) Set in the editor time, so that it is not calculated everytime we call it? The reason why we have the scriptableObject as animation asset is to be able to store such information so that we can just use them. Please don't make it recalculate everytime. The same property goes for the duration in time, it should be precalculated and stored in the animation asset itself.
     
  7. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Also gets :

    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <fb001e01371b4adca20013e0ac763896>:0)
    System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <fb001e01371b4adca20013e0ac763896>:0)
    System.Collections.Generic.List`1[T].get_Item (System.Int32 index) (at <fb001e01371b4adca20013e0ac763896>:0)
    Elendow.SpritedowAnimator.SpriteAnimation.GetFrame (System.Int32 index) (at Assets/Standard Assets/SpritedowAnimator/Source/SpriteAnimation.cs:35)
    Elendow.SpritedowAnimator.BaseAnimator.SetAnimationTime (System.Single time) (at Assets/Standard Assets/SpritedowAnimator/Source/BaseAnimator.cs:812)
    PropController.PlayAnimationClip (System.Int32 index, System.Boolean loop) (at Assets/Game/Script/Controller/PropController.cs:127)
    PropController.PlayActivateAnim () (at Assets/Game/Script/Controller/PropController.cs:143)
    ContainerController.Event_Use (ObjectBase user, System.Action`1[T] callback_EndUse) (at Assets/Game/Script/Controller/ContainerController.cs:60)
    UseAction.Use (CharacterBase controllerBase, UseAction+Parameter param) (at Assets/Game/Script/Character/Action/ActionObjectEx/UseAction.cs:65)
    UseAction.OnStarted (ObjectBase objectBase) (at Assets/Game/Script/Character/Action/ActionObjectEx/UseAction.cs:57)
    ActionBaseEx.StartAction (ObjectBase objectBase, ActionBaseEx+Parameter param) (at Assets/Game/Script/Character/Action/ActionObjectEx/ActionBaseEx.cs:185)
    ActionController.PlayAction () (at Assets/Game/Script/Character/Action/ActionObjectEx/Component/ActionController.cs:142)
    ActionController.AddPlaylist (ActionBaseEx action, ActionBaseEx+Parameter param, System.Boolean useInsertAtFirst) (at Assets/Game/Script/Character/Action/ActionObjectEx/Component/ActionController.cs:94)
    ActionController.Use (ObjectBase target) (at Assets/Game/Script/Character/Action/ActionObjectEx/Component/ActionController.cs:209)
    PlayerController.HandleCellInteraction (GridCell cell, ObjectBase currentObject, System.Boolean isKeyInput) (at Assets/Game/Script/Controller/PlayerController.cs:438)
    PlayerController.HandleMouseClick (UnityEngine.Vector3 mousePosition) (at Assets/Game/Script/Controller/PlayerController.cs:396)
    PlayerController.HandleActionBasedOnInput () (at Assets/Game/Script/Controller/PlayerController.cs:309)
    PlayerController.Update () (at Assets/Game/Script/Controller/PlayerController.cs:111)

    When setting animation time.

    the line number may be different from the original source, but this is where it is happening

    public Sprite GetFrame(int index)
    {
    return frames[index];
    }
     
  8. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    You can't get the animation duration in seconds because the animator could have an overrided framerate and that value would be incorrect.

    If you want to get the total animation duration in seconds you could calculate it like this:

    Code (CSharp):
    1. AnimationDurationInFrames * (1f / FrameRate)
    I'll look into a solution into the duration in frames and into the error. Sorry for the inconvenience.
     
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Also, please add Play with index variation. I customized it as below :

    public void Play(int index, bool playOneShot = false, bool playBackwards = false, LoopType loopType = LoopType.repeat)
    {
    SetActiveRenderer(true);

    currentOneShot = playOneShot;
    currentBackwards = playBackwards;
    currentLoopType = loopType;

    var targetAnimation = animations[index];

    // If it's the same animation but not playing, reset it, if playing, do nothing.
    if (currentAnimation != null && currentAnimation.Equals(targetAnimation))
    {
    if (!playing)
    {
    Restart();
    Resume();
    }
    else
    return;
    }
    // If the animation is new, save it as current animation and play it
    else
    {
    currentAnimation = targetAnimation;
    }

    StartPlay();
    }
     
  10. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Also it would be super cool to have normalized time versions of all the play options and settime functions. It is more common to use normalized time than actual time in seconds. So if I want to be able to set the time at exactly 50% of the animation duration then I have to calculate total animation duration as you have suggested and then work backwards to work out actual seconds.

    Also, adding custom events only supports per frame. I can understand that if this has to be per frame, but then I need to work out the frame number again if I want to add the event at say 80% of the animation duration.

    And... :D the animation window preview is really dark for my project because I am using Linear Color Space setting. I am sure display of preview can detect color setting and then display the sprite in correct color. If detection is difficult, just have a toggle box in the editor window. The sprites are really really dark.. and I can't see anything properly. Perhaps you could use the unity's provided preview instead?

    This is not a bug in Unity as you may have assumed. The tilemap editor does display correctly. At least for 2019 and 2020
     
    Last edited: Jun 25, 2020
  11. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Let's go one by one:

    The play using index, I will not add this, I have intentions to get rid of the animation list sometime in the future, and this will only encourage the use of it. The best way to use this is to have reference to the animations you want to use on your script controlling the animator.

    I'll check the normalized time versions of everything using time.

    Sadly, the events are made to trigger with the change of the frame, that means that you can't place an event between frames. That makes the use of time here pointless. This system was made this way on purpose, and for the time being I don't have plans to change it to something time based. The most I can do is to add a method that gives you the frame index of the animation giving it a time. Please, tell me if this works for you.

    I'll look into the preview window to solve the problem with linear color space.

    Also, while I work on this, I submitted the version 1.1.1 to the asset store with the following changes:
    • Fixed a bug with out of bounds index using time instead of frames on the animator.
    • Fixed a bug where the animations would play faster on the editor than ingame.
    • Improved the way the AnimationDuration of the animations is calculated.
     
  12. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Hi.

    Yes getting the frame index for time should work.
    I am also looking at the linear space preview and it seems like the way to go is to use the Unity's PreviewRenderUtility somehow..

    Thanks.
     
  13. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    I have sort of worked around the linear space issue by overriding the sprite's shader to my own custom one by using the following code.

    Code (CSharp):
    1. if (QualitySettings.activeColorSpace == ColorSpace.Linear)
    2.             {
    3.                 Shader shader = EditorGUIUtility.Load("SpriteDefaultEditor.shader") as Shader;
    4.                 sr.sharedMaterial.shader = shader;
    5.             }
    Inserted in EditorPreviewSpriteAnimation.cs

    The shader is to just force returning the linear space texture input into gamma one. :p
     
  14. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    I could be wrong, but does custom event triggers at frame 0?
    What about the case where there is only one frame?
     
  15. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there,

    You are completely true, the events on frame 0 don't trigger at the moment, is a bug I've already solved. There's an update pending with some issues solved and with some of the petitions you made.

    I'm already looking for a good solution to the linear/gamma issue with the preview window and with the preview window on the animations asset, but for the moment I'll submit the update with this.

    Thanks for the feedback again.
     
  16. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Ohhh I see! That's nice to hear, I thought I was going crazy!
     
  17. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    A new update is now ready to download, this is the changelog:
    • Fixed a bug with custom events not triggering on frame 0.
    • Fixed a bug with out of bounds index using time instead of frames on the animator.
    • Fixed a bug where the animations would play faster on the editor than ingame.
    • Improved the way the AnimationDuration of the animations is calculated.
    • Added PlayStartingAtNormalized time (without parameter, with animation name and with animation) to the animator API.
    • Added GetFrameTime (with and without FPS specified) to the animation API.
    • Added GetFrameAtNormalizedTime (with and without FPS specified) to the animation API.
     
  18. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    129
    Hi there, long time fan.

    Is there a way to modify the "play backwards" setting during runtime without modifiying any of the code base? If not, would it be possible to expose this value in your next update? I have a conveyor belt prefab and I would like to reverse the animation (50/50 chance) without resorting to negative scaling.

    Thanks
     
  19. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    I think this was mentioned in the previously, but what was the point of having editor fps not syncing to animation fps?

    I so often, change the fps by only using the slider and then forgets to change the actual fps. After couple of clips I forgot what was it before ... and then had to retrack it again. Seems a bit pointless to me.. I think both needs to be synced together?

    We also need button for remove all frames..
     
  20. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there, you can Play the same animation with the backwards parameter changed, if the animation is playing it will just update the backwards parameter, the animation will continue without cuts.

    About that, the point of having the editor fps not synced is basically to test the animations without modify them. I usually want to preview the animations, test some framerates and when I got the one I wanted, then I set it on the animation. I'm going to check if I can get a solution to both cases.

    I'll add the remove al frames button to the roadmap, thanks for the feedback.
     
  21. johajo

    johajo

    Joined:
    Apr 1, 2014
    Posts:
    23
    Hello,

    I just started using Spritedow and just wanted to say that it is really a great tool!

    Big thank you for making this.

    Jonathan
     
  22. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hey Jonathan,

    Thanks for your kind words, I'm really happy that my little tool helps people make great games.

    Thanks again for you message and ping me if you need anything :)
     
  23. mrkotfw

    mrkotfw

    Joined:
    Oct 27, 2012
    Posts:
    10
    First, thank you for the tool.

    A few bugs...

    When checking if the frame duration has been reached, there are cases for when
    Time.deltaTime
    is less than 1/60 (by 0.01). As of now, the animator skips the frame, increasing the frame duration.

    Also, when checking if the last frame is reached in a single shot, the loop shouldn't exit early because within the stop callback, playback might occur. This results in a frame being skipped.
     
  24. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    @Elendow ,

    Were you able to come up with the editor solution for the linear space darkness?

    It's just way too dark in order to animate anything properly for us. :(
     
  25. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there,

    No, I tried to make a custom shader only for the preview window, but no luck for the moment. I've been very busy with our game lately. I'll take a look this week an see if I can solve it ASAP. Sorry for the wait.

    Same for this, I didn't answer but I'm also looking to solve this bugs.

    Sorry again u.u
     
  26. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Solved on the next update ;)

    As for this, I would like your opinion on how to handle this.

    For the first issue, the animator will save "time extra time" from the last frame and use it on the next one, so, some frames will last longer or less depending on the game framerate, but the animation as a whole will have the correct duration.

    The second issue, I was unable to reproduce it, could you explain a little more the bug?

    Thanks a lot :)
     
  27. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Please Add :

    1. Remove All ( Reset ) Button
    2. Reverse All Button ( Basically reverse sort the animation frames

    It will help a lot in everyday production
     
  28. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    The next update already have the remove all button.

    The next after the next will have the reverse button.
     
    castor76 likes this.
  29. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Just updated to the latest version and the preview is indeed fixed!

    however, I found the following :

    upload_2020-11-10_22-37-36.png

    for the inspector of sprite animation. The frame lists needs to be rendered after the camera preview?
     
  30. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    That is a bug that I don't know how to fix, only happens on Unity 2018 or posterior. I've been trying to fix it since it pop out without luck.

    I recommend using the Sprite Animation window instead of the inspector for the moment.
     
  31. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Oh, I see. That's ok. It is not a big deal. I will use the editor window. Maybe you should report it to Unity if it was not happening before certain Unity version. Even if it is not a Unity bug, they will know why it happens.
     
  32. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    129
    Hi there, is there a way for the animation class to return the total animation length, in terms of time/seconds?

    EDIT: I noticed some variables are used to calculate the animation time, but does this factor in the total sequence length, including the individual time between frames?
     
  33. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there,

    The "AnimationDuration" parameter of the SpriteAnimation includes the individual time of each frame, so you can use it to get the total lenght of the animation simply multiplying it by its framerate (or the one overrided by the animator if its necessary).
     
  34. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    129
    Brilliant, thanks for this.

    A small feature request if I may... There are moments in the game where I would like to hide the sprite renderer but still have the animation ticking over.

    Despite toggling the enabled state of the SR, each time I play a new sequence it is re-enabled again (which to be fair makes sense). I can of course simply add a case for this myself in your code, but wondered if this was something you would mind adding in so I don't have to re-apply my changes in the event you submit further package updates. Would this be possible?
     
  35. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    To be honest, I had the same need some times but I don't think its something that has to be in the animator itself because it goes... against the basic functionality.

    What I did is change the color of the sprite renderer to have alpha 0, that way it's not visible, it's still active and the animator does its work as intended.

    I hope this "hack" suits you. Still, I'm going to take a look at it.
     
  36. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    I , myself is also in need of calculating the total animation time. I know this can be "calculated" but why not the animator component does this calculation for us? Have some nice API to call upon, instead of us having to create one.
     
  37. jamiewhitephd

    jamiewhitephd

    Joined:
    Jun 8, 2012
    Posts:
    129
    Fair point, I didn't think of this! That should work for now, thank you.

    RE. animation time...I agree with castor above that it would be nice to have a function/property readily available for this, but I will use your solution for the time being.
     
  38. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    383
    I am trying to create animation by creating a runtime scriptableobject. It is similar to avatar selection. When I click on the avatars their corresponding animations will play. So at first when I clicked on the image animation played. Then I click the back button and later come back to the same page and clicked on another avatar but this time the avatar did not play any animation.
    How to remove the scriptable object from the animation list. I tried removing it by destroying the scriptable object but at that time the animation is not playing. Any problem with UI animator initialize method. Is the problem with destroying scriptable objects?
    Code (CSharp):
    1.  
    2.        
    3.  public void SetupAnimationSprites(string[] images, string animationName,bool play)
    4.     {    
    5.         Dictionary<string, string> fileDownloaderUrls = new Dictionary<string, string>();
    6.         for (int i = 0; i < images.Length; i++)
    7.         {
    8.             if (string.IsNullOrEmpty(images[i]))
    9.                 continue;
    10.             string url = awsManager.GetSignedUrl(images[i]);
    11.             fileDownloaderUrls.Add(images[i], url);
    12.         }
    13.         spriteDownloader.Download(fileDownloaderUrls, PathHelper.DefaultDownloadsPath, (status, sprites) =>
    14.         {
    15.             if (!status)
    16.             {
    17.                 Logger.Error("Failed to get avatar animation sprites");
    18.                 return;
    19.             }
    20.             int spriteCount = sprites.Count;
    21.             spriteAnimation = ScriptableObject.CreateInstance<SpriteAnimation>();        
    22.             spriteAnimation.Frames = sprites;
    23.             spriteAnimation.FramesDuration = new List<int>(new int[spriteCount]);
    24.             spriteAnimation.FPS = 24;
    25.             spriteAnimation.FramesDuration.Populate(spriteAnimation.FPS / spriteCount);
    26.             spriteAnimation.name = animationName;
    27.             Debug.Log("Values are "+ sprites.Count+"::"+play);
    28.                 if (uiAnimator.animations == null || uiAnimator.animations.Count == 0)
    29.                 {                
    30.                     uiAnimator.Initialize(play, new List<SpriteAnimation>() { spriteAnimation }, spriteAnimation.name);
    31.                 }
    32.                 else
    33.                 {
    34.            
    35.                     uiAnimator.animations.Add(spriteAnimation);            
    36.                 }
    37.        
    38.         });
    39.     }
    40.  
    41. public void RemoveAnimations()
    42.     {
    43.        //Destroying scriptable object
    44.        if (uiAnimator.animations.Count > 0)
    45.            Destroy(spriteAnimation);
    46.     }
    47.  
    48. Below code where-I call the above SetupAnimationSprites() method of UIAnimatorManager class
    49.  
    50. uiAnimatorManager.RemoveAnimations();//Destroying the scriptable object
    51. uiAnimatorManager.SetupAnimationSprites(animationImages, "ProfileNamePageAnimation", true);
    52.  
     
    Last edited: Feb 9, 2021
  39. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there, I don't quite understand what are you trying to achieve. Could you give some context? Thanks :)
     
  40. zyonneo

    zyonneo

    Joined:
    Apr 13, 2018
    Posts:
    383
    Updated my question and code.Thanks
     
    Last edited: Feb 9, 2021
  41. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Ok, the problem is that you are destroying the Animation asset but not removing it from the list. You should call the initialize method again with the new animation or simply clear the animation list and adding the ones you want.

    Or, if you are using the last version of the plugin, you can call the PlayAnimation method with the animation as a parameter, that way is not necesarry to have it added to the animation list.

    Hope this helps :)
     
  42. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Hi.

    We have some major problem with the animation system.

    When you author animation at say 60fps, and have the playrate like 2 or 3 times and then have the actual rendering fps low like 30fps then animation playback speed is significantly affected by the rendering fps.

    I don't mind frame skipping, but honestly events and the overall play duration should remain close to what is intended. Right now, rendering fps affects both so much that the overall play duration becomes a lot more longer than it should be.

    Any idea how we can over come this?
     
  43. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi there,

    Im going to run some test and check if I can get a solution to this. I'll update you if I find something.
     
  44. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    Hi again,

    I've tested the animator at a low FPS and it works as intended, there's no frame skipping and the events work just fine. Obviously the rendering is slower because of the slower FPS of the game, but that is a problem of the game itself.



    Here's a video result of my testing, if this is not what you meant, could you record a video so I can see clearly what you are meaning?

    Thanks :)
     
  45. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Humm.. your video does show low fps, but the animation itself also looks like it is running slow motion. Can you test it with animation clip fps setting to be 60fps and the play rate to like 4 times? So the animation at 60fps should play at the normal speed, which is default and then play back with rate of 4 times speed on rendering fps of 10 or 20fps?

    What to be expected.

    If rendering fps is lower than specified animation fps or high play rate causes higher animation fps than rendering fps, then frame skip should happen except the event handling, so that the overall play duration is kept as much as to the mathematically correct duration. If event handling cant trigger at the correct timing then it should trigger at the next frame at least..

    What this means is that if animation fps is 60fps and game is running on 30fps rendering then it should frame skip to rendering every second frame except trying to run the events as close to the correct timing as possible.

    Running game on slower computer resulting in low fps should not affect overall animation duration. Otherwise on slower pc, the game will just run slower which is not acceptable. Slower pc with low rendering update fps should display game at discreet, not smooth playback, frame skipping instead of whole game being in slow motion.

    If there are no frame skipping happening for lower rendering fps than animation fps then the whole animation system becomes unreliable, and actual fps means nothing because it depends on the computer you are running..haha

    I think Unity animation system works as I have described, except that their event system maybe running at the separate update system..
     
    Last edited: Mar 21, 2021
  46. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    I'll check if I can made the frame skipping system.
     
  47. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84


    Is this the result you expected? I'm skipping frames, checking the events of the skipped frames in order to not lose those (so they can fire on different frames, but in this case is the correct thing). The animation duration is the same in time in any framerate.

    If this is ok I'll send the update to review, including this, the reverse all buttons and the animation duration (in time) included in the animation class.
     
  48. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Yes that seems to be right!
    I can give a test !
     
  49. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,426
    Also please check for the reverse case. If rendering fps is higher than the animaton fps, it needs to wait to play the next frame.
     
  50. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    84
    It works correctly when the game FPS is higher than the animations FPS.

    I submitted an update to Unity and its pending review, this is the changelog:
    • Added Animation Duration in seconds to the animation API.
    • Added "Reverse Frames" to the frames list.
    • Improved performance of the animations on low FPS games.