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 Crumpet · Oct 10, 2013 at 12:26 PM · animationsmultiple

how to make one script with different animations attached

Okay so this is my first post. Anyway I made a script:

 using UnityEngine;
 using System.Collections;
 
 public class MusicOnOff : MonoBehaviour
 {
     private bool  Trigger = false;
     public GameObject Button;
     public GameObject Speaker;
     Transform DoorGameObject; 
     private bool  HasTriggerBeenUsed = false;
     void  OnTriggerStay ()
     {
         if (Input.GetKeyDown("f") && !HasTriggerBeenUsed)
         {
             // toggle audio on/off on audiosource of speakers
                 AudioSource source = Speaker.GetComponent<AudioSource>();
                 source.enabled  = !source.enabled;
             {
                 Trigger = true;
                 if (Trigger)
                     Button.animation.Play ("Buttondown");
                     }
                 }
             }
         }

and where it says: Button.animation.Play ("Buttondown");

I want to be able to edit the animation so it can be changed easily like making it a public GameObject kind of and the script would not have to be edited. If this can't be done I can always try something else though.

The script also may not be great it is my first script made by myself it was probably one of the simplest things I could make so if it could be left the way it is it would also be appreciated.

Comment
Add comment · Show 4
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 KiraSensei · Oct 10, 2013 at 12:28 PM 0
Share

Please format your code : look at this question

avatar image Crumpet · Oct 10, 2013 at 12:46 PM 0
Share

Sorry about that I'm new as I said. Is it better now?

avatar image KiraSensei · Oct 10, 2013 at 12:50 PM 0
Share

yep :)

Why do you want to edit the animation ? If you want different animations, create different animations, and play the one you want. But do you really want an animation on a button ??

avatar image Crumpet · Oct 10, 2013 at 01:24 PM 0
Share

Yeah I want different animations. I wanted the buttons to go down like you're pressing it except there is more than one button. This means if I use the same animation script to make the button go down it'll teleport to the position of the other button. Hard to explain. Yeah I could do what you said but that'd require more scripts and.. Well I have 13 buttons

2 Replies

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

Answer by KiraSensei · Oct 10, 2013 at 01:39 PM

I understand your problem.

Maybe you don't need animations at all. Maybe you can use THIS. It will help you move your button from a position to another smoothly. If not, I'm afraid you'll have to make different scripts, or at least one script containing the handling of the 13 buttons at once ...

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
0

Answer by Crumpet · Oct 10, 2013 at 02:26 PM

Yeah that looks a lot like what I needed thank you so much anyway on my first post. :D

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 KiraSensei · Oct 10, 2013 at 02:34 PM 0
Share

So please accept my answer by ticking the check next to it :)

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

16 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Multiple animations for a character 1 Answer

Animation on android doesn't work 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

MonoBehaviour with Multi-Inheritance 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