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 $$anonymous$$ · Jun 07, 2014 at 08:48 AM · animationclickcallon

How to make left clicking start an animation?

I'm trying to make it so that when I left click my shield will come out to block. I have the animation, now I need to know how to call in the animation from the script (.cs) I would not recommend Unity for just starting in coding, haha. I just need to know how to do it. So yeah, also if you can help me out by adding what it does // or */ whatever it is in .cs that is used to define, that'd be great since I don't just want answers, I want to learn.

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

2 Replies

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

Answer by $$anonymous$$ · Jul 15, 2014 at 10:19 PM

function Input.GetMouseButtonDown(0)) } play.Animation("AnimationName"); }

Worked for me. (Or something similar, mess around with it if it doesn't, I'm doing this off memory.

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 robertbu · Jul 15, 2014 at 10:21 PM 0
Share

@$$anonymous$$ - your memory is a bit mixed up. To work, your code would be:

 if (Input.Get$$anonymous$$ouseButtonDown(0)) {
     animation.Play("AnimationName");
 }

Also, you seem to be answering your own old question?

avatar image $$anonymous$$ · Jul 18, 2014 at 01:27 AM 0
Share

@robertbu $$anonymous$$y bad. And I decided I should leave the answer so that people looking for an answer on here don't have to search through the whole document @Fornoreason1000 provided. Even though I am grateful and it taught me some things, I find it'd be easier for everyone else.

avatar image
0

Answer by Fornoreason1000 · Jun 07, 2014 at 09:21 AM

Ok.... For coding practice you should try unity Gems or even just you tube Google C# tutorials often gives good results.

Do you know if your using Legacy or Mecanim Animations? the method t control them in C# is different for the two types. its more or less the same... but basically you use a state machine to check and set which animation state you are in... then make an condition that stipulates whenever you press the left moue button.. you set your Animation state to the state and your animation will play Mecanim tutorials http://docs.unity3d.com/Manual/MecanimAnimationSystem.html http://docs.unity3d.com/ScriptReference/Animator.html www.youtube.com/watch?v=Xx21y9eJq1U

Legacy http://docs.unity3d.com/420/Documentation/Manual/Animations40.html http://docs.unity3d.com/ScriptReference/Animation.html C# tutorials

http://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx www.youtube.com/watch?v=SXmVym6L8dw www.burgzergarcade.com/

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

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

21 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 avatar image avatar image avatar image avatar image

Related Questions

How to play sprites animation on the place that we click? 0 Answers

2D: How to Move On Click with Creatable (On Click) Waypoints 1 Answer

How To Play Animation On UI Button Click Please... Im Going To Freak Out Please Enter And Help Me 2 Answers

Object reference not set to an instance of an object 1 Answer

How to call an Animation? 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