Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Donilias · Jan 18, 2012 at 01:41 AM · animationkey

wait seconds before it's possible to press a key

Hey everyone.

My problem is, how to fix this.

If an animation is playing, it's impossible to press the left and right mousebutton. So you need to wait till the animation end. then you can press them. How to do that?

Please help.

I thought something with yield WaitForSeconds()?

Thanks in advance.

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
1
Best Answer

Answer by ByteSheep · Jan 18, 2012 at 03:27 AM

I believe you don't have to go as complicated as using yield etc, you can just check whether the animation has stopped playing:

 if(!animation.IsPlaying("Animation Name"))
 {
    if(//mouse input)
    {
    //animation isn't playing and mouse got pressed so move
    }
 }


Not sure if IsPlaying is the proper spelling, it might be isPlaying but you can just try it out - hope this helps :D

Comment
Add comment · Show 11 · 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 Donilias · Jan 19, 2012 at 12:39 AM 0
Share

this is what i got, and it still don't works.

if(Input.Get$$anonymous$$ouseButton (1))

{

//animation isn't playing and mouse got pressed so move

}

$$anonymous$$aybe i should replace

"//animation isn't playing and mouse got pressed so move" in something else?

But i don't know in what.

Some help please

avatar image ByteSheep · Jan 19, 2012 at 01:18 AM 0
Share

Here's an example of how to use this, we'll use an animation called TestAnimation just to show you what it should probably look like:

if(!animation.IsPlaying("TestAnimation")) {

if(Input.Get$$anonymous$$ouseButton (1)) {

//animation isn't playing and mouse got pressed so play animation

animation.Play("TestAnimation"); }

}

It's as simple as that just replace "TestAnimation" with the name of your actual animation that you want to play when mouse is pressed. If you still have troubles or you get errors let me know :)

avatar image Donilias · Jan 19, 2012 at 04:56 PM 0
Share

no, it doesn't work :(

avatar image ByteSheep · Jan 19, 2012 at 06:48 PM 1
Share

Are you getting errors? Or is it not giving you the affect you want? The script above should be checking whether a certain animation is playing and if it isn't, then if the player presses the mouse button the animation can play.. Is the animation looping? cause if it doesn't stop playing then this code is useless. I need a little more info on what exactly is or isn't happening.

avatar image Kilometers · Jan 19, 2012 at 10:44 PM 1
Share

So, the problem is that you can not aim when the reload animation is playing, yes? And you want to be able to use the right mouse button to aim, even if the reload animation is playing? WEll, even if this isn't your problem, I believe you will need to post the controller code if anyone is going to be able to help you.

Show more comments

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

6 People are following this question.

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

Related Questions

Unity Animation Window - Bizarre Animation Length Bug 4 Answers

Door animation after press a key 2 Answers

play animation when press key 2 Answers

Animation controller 2 Answers

Animation script 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