Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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
8
Question by pauldstewart · Feb 17, 2011 at 11:19 AM · animationpause

Pausing an animation

I don't see a straightforward way to pause an animation. Presumably I first have to log the current frame when I click a button or press a key, and then start the animation again from that frame.

The question being really, how do I get the current frame of an animation? Or is there a better way to pause an 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

4 Replies

· Add your reply
  • Sort: 
avatar image
14
Best Answer

Answer by TheDemiurge · Feb 17, 2011 at 11:37 AM

AnimationState

From the docs under Animation: (no example under AnimationState)

// Make all animations in this character play at half speed
for (var state : AnimationState in animation) {
    state.speed = 0.5;
}

so speed = 0 will pause it :)

Comment
Add comment · Show 1 · 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
avatar image pauldstewart · Feb 17, 2011 at 11:40 AM 0
Share

Thank you......

avatar image
26

Answer by Setsuki · Nov 26, 2012 at 10:46 PM

speed = 0 doesn't work in my case, and I have many animations thaat can be playing. In my case, I litteraly want my character to freeze, so I simply used

 animation.enabled=false;

Worked like a charm.

Comment
Add comment · Show 6 · 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
avatar image petey · Jan 02, 2014 at 01:19 AM 0
Share

Awesome thanks for posting this! Way simpler than the crazy stuff I was trying to do :)

avatar image Wessels · Dec 15, 2014 at 09:28 AM 0
Share

When using animation.enabled=true will it start the animantion again or continue where it was stopped?

avatar image georgepiva · May 19, 2015 at 02:48 PM 0
Share

@Wessels The answer is yes. It will continue from where it stopped.

avatar image BEFaughnan · Jul 07, 2016 at 08:28 PM 3
Share

When I use this method the animation skips ahead where it would have been when turned back to true. Is anyone else experiencing this?

avatar image Brumpet · Jul 30, 2016 at 09:49 PM 0
Share

Just used my one and only rep point on this, dont know how to get them, and probably will never get another. Seriously, this works so well, ;D;D;D

Show more comments
avatar image
6

Answer by Hritik-Mahirrao · Jul 01, 2015 at 05:44 PM

You can use 'enabled' property to stop/pause animations

animator.enabled = false;

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
avatar image
1

Answer by Madhur26 · Jun 26, 2017 at 07:57 AM

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class pausescript : MonoBehaviour {

 public bool paused;
 // Use this for initialization
 void Start () {
     paused = false;
 }
 
 // Update is called once per frame
 void Update () {
     
 }

 public void Pause(){
         paused = !paused;

     if (paused) {
         Time.timeScale = 0;

     } else if (!paused) {
         Time.timeScale = 1;

     }

 }

}

This worked for me.

Comment
Add comment · Show 3 · 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
avatar image remingtonspaz · Apr 04, 2019 at 03:16 AM 1
Share

This is incorrect. This pauses the whole game ins$$anonymous$$d of just the animation.

avatar image highpockets remingtonspaz · Apr 04, 2019 at 08:25 AM 0
Share

If the animation is on its own layer, setting the weight to 0.0f is an effective approach and also lerping to zero can have a smoother effect.

avatar image remingtonspaz highpockets · Apr 13, 2019 at 04:07 PM 1
Share

Sure, but I don’t see what that has to do with this answer?

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.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Playing animation frame by frame by procedural controller 5 Answers

What is the difference between 'Animator' & 'Animation'? 1 Answer

Can the animation editor create local rotational data? 3 Answers

Animation Problems 1 Answer

Pause Animation Clip wiothout rewinding 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges