0
\$\begingroup\$

I have an animation (fishing) I want to play backwards when the player catches something or cancels the action.

Playing the animation backwards is as simple as setting the speed to -1, ie:

anim.SetFloat("direction", -1.0f);

However, my fishing animation keeps playing until I have caught something, or cancel the animation. This means that the last frame of the animation is showing, but the time of the animation is still going.

So

  • the animation reaches the last frame
  • then I stand there for 8 seconds,
  • I catch something, so I change anim speed to -1
  • anim will now reverse those 8 seconds I was "standing still" first, before it even reaches the actual animation.

I need to stop the animation time on the last frame (without leaving the animation), so that reverse will be instant. And to not exit the animation until the reverse is finished. Maybe there is some other way to do it, but I can't figure it out.

I could create a seperate animation for when I want it to go backwards, but that seems sloppy.

\$\endgroup\$
0
\$\begingroup\$

Have you considered having a Boolean of fishing and catching. You will want separate animations for different states such as cast, fish, catch, snag and then blend nicely between them.

The fishing can endlessly loop and then blend into various catch animations or other states like cancel when the parameters are met or lost.

//create parameters in the animator and update from a player state or some sort of controller script.
    anim.SetBool("myfishingparameter", isFishing);

You can achieve your original question by either triggering or invoking a method or event during the -1 playback and just end it before the standing part of the animation. I think you will prefer to blend between animations once you set them up.

\$\endgroup\$
  • \$\begingroup\$ Thanks. I ended up going as simple as possible and just force the blend to go to a playerCatching animation if playerfishing is set to false. If there is a fish I set the sprite of the floater to the fish, otherwise I keep the floater sprite. Its good enough I guess. \$\endgroup\$ – Green_qaue Jun 7 '17 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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