• 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 question was closed Jun 28, 2011 at 08:51 PM by logging_out for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by logging_out · Sep 19, 2010 at 01:06 AM · elevator

Elevator Script

Since the last script I wanted was too complicated I'm settling for a simpler script. Well, I'm pretty sure it's simpler. Basically I need a script that when a trigger is touched the elevator moves up a floor then back down. What script would do this for me? Note: There are only two floors.

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

  • Sort: 
avatar image
1

Answer by name111 · Sep 19, 2010 at 04:06 AM

hey, i think i have what your looking. i found a script on this website for opening a door(found like 1 hour ago), so its NOT mine anyway theres 1 problem its so simple t will do what you want but only 1 animation so you would push the button and it would play the animation from the start and always from the start. so if you cant edit it because your not script savvy i recommend making the animation of the elevator go up then skip a lot of frames (depending on how long you want it to stay) then begin adding the return animation. therefore it will be in 1 animation and will not restart and disappear back to the start animation area. so if you want to use this elevator again to return back down sorry u cant with out an alternate way down or if u can edit the script to do so. anyway im not gonna keep u reading anymore heres the script....if im up for ill try to add the return part of it for better interface, i also added a sound for you(add audio source((plays on keydown))

var theAnimation : AnimationClip;

function OnTriggerStay () { if (Input.GetKeyDown("e")) { animation.Play(); //Other actions here if (audio) { audio.Play(); audio.loop = false; } } }

Comment
Add comment · Show 5 · 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 logging_out · Sep 24, 2010 at 11:05 PM 0
Share

This should work. I don't have the time to test it, but thank you for your help. Although what would I need to change to play the animation and audio source when my box collider is touched?

avatar image name111 · Oct 01, 2010 at 07:47 PM 0
Share

What exactly do u mean by touched? on mouse hoover or on mouse click, etc.?

avatar image logging_out · Oct 08, 2010 at 09:59 AM 0
Share

When the player or an enemy touches it.

avatar image name111 · Oct 11, 2010 at 03:25 AM 0
Share

wat do u mean touches.... interacts? clicks? hits into it while walking?? be specific

avatar image logging_out · Oct 14, 2010 at 02:32 AM 0
Share

When the player or enemy collides into the box collider. How much more specific do you want.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

No trampolines work... 0 Answers

Elevator script problem (Java) 1 Answer

Performance of Mathf.Clamp vs if-else statement? 1 Answer

How do I add bots in android? 2 Answers

Turning when not seen. 0 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