Announcement

Collapse
No announcement yet.

Getting an animations total play time after increasing its playrate

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting an animations total play time after increasing its playrate

    Hi guys, in the game I'm building I need to know the total play time of all my attacks.
    I usually just look up the time the animation editor gives me at the last frame of an animation.

    But recently I found that if I increase the frame in between time while making the animations in blender and speed them up when calling play custom anim using the Playrate parameter the animations look way smoother and are a big improvement compared to having to shorten the inbetween frames in blender to get them to play faster.

    I know that blender is making animations 30fps.

    So if I speed up the frame rate of a 15 frame animations that plays for 0.5 seconds to 1.5 of a frame per frame. How long will the animations have played for?

    I know this should be simple math for a programmer, but I'm a bit dislexic and I'm having a real hard time figuring out the conversion.



    float PlayRate = 1.5f;
    FireInterval[0] = 0.5f;

    // my fire interval matches the animations normal lifetime, when the playrate is 1.0f;
    //so right now the animation will finished before the fireinterval since the playrate is 1.5
    // I'm having a hardtime figuring out the time conversion

    GamePawn(Owner).AttackAnim.PlayCustomAnim('Gamepla yModel_LAttack1', PlayRate , 0.0f,0.0f);

    #2
    If you get the animation play rate at normal speed (there are functions for doing this), you can multiply it by the play rate.

    On the easier side, PlayCustomAnim looks like:

    PHP Code:
    /**
     * Play a custom animation.
     * Supports many features, including blending in and out.
     *
     * @param    AnimName        Name of animation to play.
     * @param    Rate            Rate animation should be played at.
     * @param    BlendInTime        Blend duration to play anim.
     * @param    BlendOutTime    Time before animation ends (in seconds) to blend out.
     *                            -1.f means no blend out.
     *                            0.f = instant switch, no blend.
     *                            otherwise it's starting to blend out at AnimDuration - BlendOutTime seconds.
     * @param    bLooping        Should the anim loop? (and play forever until told to stop)
     * @param    bOverride        play same animation over again only if bOverride is set to true.
     *
     * @return    PlayBack length of animation.
     */ 
    so I think that's already handled there, just look at the returned value.

    Comment


      #3
      ohh snapp, that's so awesome! ^.^ Thank you so much would have never noticed this

      Comment


        #4
        Yeah it works perfect. Dude you are awesome thanks

        Comment

        Working...
        X