• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Happystudio · Nov 16, 2017 at 02:28 AM · animationanimatortime

How do I stop animation from going past end time

This is similar to this unanswered question https://answers.unity.com/questions/1050555/how-to-stop-animation-from-going-past-the-last-fra.html

I have an animation that I want to play forward when the user presses the [left arrow key] and play backwards when the user pressed the [right arrow key]. This works fine by changing the speed multiplier of the animation between 1 and -1, however, it seems the animation time continues so if the user presses one way and then waits and then presses the other way the animation is not visible for some time as the animation time is outside that of the actual animation.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Przemo0c · Nov 16, 2017 at 09:10 AM

Okay I have heard about the speed multiplayer of "-1" way of doing that, but I also did tried it and it did not work for me in 100% of the times. This is going to be a lesson, a bit long one but it works 100% Personally I would do something like that : if you're using Animator Component, Click to create new animation (Like here) alt text Then record your animation as you want it to be, then create second animation inside the same Animator > choose dropdown menu > create Animation > Then Open Animator Layers (You should have sth like this) alt text And then you will have to create new Panel (So the window looks like the one I have showed you) > click on the grid > Create State > Empty > Name it as you want (I named it Start - This is the Yellow Panel ) then click on your created Panel > Set as Layer Default State and then > Click Again on your Panel > Make Transition > Connect it with your first (in your playing order) Animation > Then From your first Animation Click again > Make Transition > Connect it with your second Animation > Then Connect your second animation back to the panel you created and set to default. (So it looks like the image I have provided). Now we wanna go to creating parameters, you need to find the tab parameters that is on the left (Look at second screenshot) click that "+" icon > Bool > Name It as you want. Now we're going to be clicking on those arrows you have created as transitions (starting from the first gray one), if you click on it in Inspector tab you will have section "Conditions" and again click there "+ " icon > Choose your parameter set it to depending on the logic you are using false/true. My transition arrow condition since my parameter is named "_isVisible " order (starting from Start) is true > false > false.

And now the easiest part if you want your animation to play via coding : Mine looks like this, this one shows the panel :

 panel.GetComponent<Animator>().SetBool("_isVisible", true);

so general idea would be :

 [YourGameObject].GetComponent<Animator>().SetBool("[name of your parameter]", true);

Anyways I know it is a lot to read and learn, but I can assure you that it is going to work, if you have any questions go ahead and ask :P


1a.jpg (35.2 kB)
2a.jpg (93.6 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

192 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animator & movements 1 Answer

Jump to specyfic time/frame in current animation using animator? 2 Answers

How to end an animator animation using time? 0 Answers

How do I set the time of an animation playing in the animator (Mechanum) 5 Answers

2D Animation does not start 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges