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 /
This question was closed Jun 25, 2011 at 10:29 PM by jimmyismike for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by jimmyismike · Jun 25, 2011 at 09:42 PM · animationloop

Animation Looping Help

Here is my scrpt

 function Update () {
 if(Input.GetKeyDown("mouse 0")) {
     animation.Play("m4shoot");
 }
 if(Input.GetKeyUp("mouse 0")) {
     animation.Stop("m4shoot");
 }
 }

When i let go of mouse 0 the animation stops even if its not done. Can you tell me so when you let go of mouse 0 the animation finishes instead of just stops.

Comment
Add comment · Show 3
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 Bunny83 · Jun 25, 2011 at 10:40 PM 0
Share

What the... Why you closed the question? And with the reason that the right answer was accepted??? No answer is marked as accepted ...

Dude this way you won't get friends here. This page is like a wiki. It's a collection of good questions and good answers to help the community.

avatar image jimmyismike · Jun 25, 2011 at 11:12 PM 0
Share

So i dont lose karma. I'm a begginer and since i have begginer questions they get thumbed down and i lose karma.

avatar image Bunny83 · Jun 26, 2011 at 02:40 AM 0
Share

lol? you get karma if you accept an answer... It still can be downvoted...

There is no problem with beginner questions. The (old) FAQ states that no question is to "noob" as long as it has something to do with Unity and it's of interest to at least someone else on this planet.

Closing an unsolved question is the worst you can do! esp. with the wrong reason. That's why the old system only allows 3000+ users to close a question and only when it gets 5 votes to close.

3 Replies

  • Sort: 
avatar image
-1

Answer by HolBol · Jun 25, 2011 at 09:45 PM

Well, if you have a neutral animation, and a shoot animation, you would use animation.CrossFade(), if not, use animation.Pause.

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 Steven-Walker · Jun 25, 2011 at 10:07 PM

If you want the animation "m4shoot" to play fully, remove the key up handler that stops it!

 function Update () {
    if(Input.GetKeyDown("mouse 0")) {
        animation.Play("m4shoot");
    }
 }
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 Bunny83 · Jun 25, 2011 at 10:24 PM 0
Share

He has a looping animation so it won't stop

avatar image
0

Answer by Bunny83 · Jun 25, 2011 at 10:23 PM

Shooting animations shouldn't be looping. You should handle that in your shooting logic. You would fire the animation everytime you shoot a bullet.

The point of looping animations is that they are never done so you need the animation to be a "normal" once-animation.

 var rateOfFire = 5.0;
 private var shootDelay = 0.0;
 private var shootTimeOut = 0.0;
 
 function Start()
 {
     var shootAni = animation["m4shoot"];
     shootDelay = (1.0/rateOfFire);
     // This will adjust the speed of the animation ot match the rate of fire
     shootAni.speed =  shootAni.length / shootDelay;
     shootAni.wrapMode = WrapMode.Once;
 }
 
 function Update ()
 {
     if(Input.GetKey("mouse 0"))
     {
         if (Time.time > shootTimeOut)
         {
             shootTimeOut = Time.time + shootDelay;
             animation.Play("m4shoot");
             // shoot your bullet here
         }
     }
 }

The code isn't tested but it should work that way ;)

Comment
Add comment · Show 2 · 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 jimmyismike · Jun 25, 2011 at 10:26 PM 0
Share

I already have shooting script that has ammo and stuff. Yours would mess up what I have. Please just answer the question as asked.

avatar image Bunny83 · Jun 25, 2011 at 10:29 PM 0
Share

That doesn't make any sense. A looping animation is NEVER done because it's looping. Stop will stop the animation at the current position. If you want the animation to stop at the end it have to be a non looping animation.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to play an animation in a loop? 2 Answers

Animations in the animator not looping 1 Answer

How to synchronize sound and animation loop? 2 Answers

Animation glitch when looping. 1 Answer

Looping animation while key down 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