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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by cocleu · Oct 05, 2013 at 03:03 AM · animationframegetmousebuttondownanimation.play

Animation play on multiple object

Something wrong in my animation play on multiple object

i everybody,

I have 9 panels, each panel has 30frames animation and start every 10frames (1st panel start at frame 0, 2nd panel start at frame 10......to 9th panel..) and each animation is set wrapmode to play once (it will look like a backdrop on stage).

here is my code:

 var panel1 : GameObject;
 var panel2 : GameObject;
 var panel3 : GameObject;
 var panel4 : GameObject;
 var panel5 : GameObject;
 var panel6 : GameObject;
 var panel7 : GameObject;
 var panel8 : GameObject;
 var panel9 : GameObject;
 
 function Update (){
 if (Input.GetMouseButtonDown(0))
 panel1.animation.Play("panel1");
 panel2.animation.Play("panel2");
 panel3.animation.Play("panel3");
 panel4.animation.Play("panel4");
 panel5.animation.Play("panel5");
 panel6.animation.Play("panel6");
 panel7.animation.Play("panel7");
 panel8.animation.Play("panel8");
 panel9.animation.Play("panel9");  
 }

After insert above script, 9 panels play animation when game start (not left click yet) and look like a mess.

when i deactive above script and set every animation to "start automatically" it's work fine.

But i want them play when i click left mouse button.

Thanks.

Comment
Add comment · Show 1
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 cocleu · Oct 05, 2013 at 03:50 AM 0
Share

Thanks clunk47 and tw1st3d, i'm feel brighter now.

1 Reply

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

Answer by clunk47 · Oct 05, 2013 at 03:18 AM

You are only firing panel1 animation. You need to open and close your if statement with brackets, just like your Update function.

 function Update()
 {
     if(your condition)
     {
         Do your thing.
         Do your other things.
         panel3, panel4, panel5, etc...
     }
 }
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 tw1st3d · Oct 05, 2013 at 03:26 AM 1
Share

Just to explain to @cocleu The reason you must do this, is because with program$$anonymous$$g, you can ignore {} wraps if your conditional statement only has one line of code inside of its scope

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

17 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

Related Questions

Can I make animations snap to a frame? 1 Answer

Select frame for Animation 1 Answer

Call a function dependent on frame of animation? 2 Answers

Animation won't complete unless button is held 1 Answer

Animation doesn't fully play. 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