Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
0
Question by uberdood12 · Sep 11, 2011 at 03:39 PM · animationmovement

Stopping all movement along axis?

Is there a way to stop all movement when a button is pressed.

So what I would like to do is when I play an animation, with the Input of a button, the character stops moving along any axis.

 function Update () {
       if(Input.GetMouseButton(0))
       animation.Play("my_animation");
 }

If there is a way, what should I add in to stop all movement on the input of a key?

Thanks for any incite into this!

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 japanitrat · Sep 11, 2011 at 04:42 PM

animation.Stop(); stops all currently active animations, but also rewinds it. If you want to pause an animation, you will need to set its speed down to zero.

 for (var state : AnimationState in animation) {
     state.speed = 0;
 }

Be careful though, the animation is still "playing", so if you want to play it again, you just need to set the speed to 1 (normal) again.

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 uberdood12 · Sep 11, 2011 at 08:25 PM 0
Share

I should have been more clear on my question, I was more looking for a script that stops movement along the x,y and z axis on input of a button.

So if I'm using a third person controller, If I hold down the button then the speed that I'm moving at is set to 0, so I am not moving anywhere.

avatar image japanitrat · Sep 12, 2011 at 09:55 AM 0
Share

if you have control over the script that makes the movement (preferred), you first look for the "pause" key and if it has been pressed, you do not process any other keys in that behaviour.

if not, just set the x/y/z components to a fixed value as long as the button is pressed (namely to the values that were present when the user started to press the key).

avatar image uberdood12 · Sep 12, 2011 at 12:06 PM 0
Share

All right thanks, I will try it out!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Help with mouse and keyboard movement. 0 Answers

Script on moving object doesn't work? 1 Answer

How would I script a simple path animation in C# 1 Answer

Animation / Distance 0 Answers

Animation not working correctly on moving object 1 Answer


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