Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 hugemaggot · Dec 02, 2010 at 08:55 PM · animationdoor

animate only when clicked

when i animate something such as a door opening and closing i want the animation to start only when i click on it. at the moment it only happens once when i start the game or if i put it on loop.

please can anyone help me?

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

3 Replies

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

Answer by ReDespawn · Dec 02, 2010 at 09:27 PM

Make a "close" animation and then a "open" animation. Then put this script on the door. It should work!

var player : Transform; var dist = 3;

function OnMouseOver(){ if ( Vector3.Distance( door.position, transform.position ) < dist ){ if (Input.GetMouseButtonDown(0)){ animation.Play("open");

if ( Vector3.Distance( door.position, transform.position ) < dist ){ if (Input.GetMouseButtonDown(1)){ animation.Play("close"); } } }

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 chika · Dec 02, 2010 at 11:14 PM 0
Share

Hi, How would you create a similar script for an iPhone application using touch control?

Thanks

avatar image hugemaggot · Dec 03, 2010 at 07:16 PM 0
Share

to redespawn when i copy the script you have given me an error comes up saying expecting }, found

avatar image
0

Answer by Uriel_96 · Dec 02, 2010 at 09:21 PM

what you need to do is something very simple. You need to add a script that at the exact moment you want you only put

animation.Play("open");

On the quotes you put the name of the animation you have.

If your case is a door I recommend you to watch this video: http://www.youtube.com/watch?v=jDgvO7wtUMg&feature=related and the others videos to.

if you mean of put a GUI put something like this:

if (GUI.Button(Rect(10,70,50,30),"open")){
animation.Play("open");
}

Or if you want something like clic in the door and then it opens you may see this: http://answers.unity3d.com/questions/28251/how-to-perform-a-mouse-click-on-game-object/28252#28252

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 chika · Dec 02, 2010 at 10:20 PM

Hi, How would you create a similar script for an iPhone application using touch control?

Thanks

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

No one has followed this question yet.

Related Questions

Triggering door animation with collider 2 Answers

Trigger door animation with external trigger 1 Answer

A node in a childnode? 1 Answer

Maya to Unity Animation using Box Colliders 1 Answer

Camera animations? 2 Answers


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