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 question was closed Mar 30, 2014 at 01:04 PM by AlucardJay for the following reason:

Other : Asking for Scripts

avatar image
0
Question by Joxerbrown · Mar 29, 2014 at 09:32 PM · slidingdoors

How do I make A script to open 1 sliding door and another to open 2 sliding doors?

Hi all, Im not very good at scripting, in fact i know pretty much nothing and I am trying to learn as I go, I am making a game in unity and I have sliding doors, barns, one has 1 sliding door and the other has 2 sliding doors, in opposite directions. I am using Javascript. And I am stumped as to how to open them without using animations. thanks

Comment
Add comment · Show 5
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 iwaldrop · Mar 29, 2014 at 09:56 PM 0
Share

You can use the same script if all it does is open every linked door. In one case you'd only link one door, whereas in the second you might link two or three doors.

Ex:

 public Door[] door;
 
 public void OpenDoors()
 {
     foreach (Door door in doors)
         door.Open();
 }
avatar image Lo0NuhtiK · Mar 29, 2014 at 10:02 PM 0
Share

An excellent way to open doors or make new ones ->

["Open, says-uh-me"] (untested code)

avatar image Joxerbrown · Mar 30, 2014 at 01:22 AM 0
Share

Lo0Nuhti$$anonymous$$ i cant see anything in that page you linked, none of the comments mention anything about doors that i can see.

iwaldrop how would i use that code? i assume i need to create a cube with 'is trigger' and uncheck the mesh render, but how would i then get the door(s) to move, I forgot to mention earlier that i would like to use a keypress "f" to open the doors.

thanks for any help i can get

avatar image iwaldrop · Mar 30, 2014 at 03:05 AM 0
Share

What is sounds like you need is a game object with a Sphere Collider on it that is setup to be a trigger, a script that will let the user know that they can hit the 'f' key to open the door, and a script that listens for the 'f' key being pressed (while the user is in the collider) which would then send a message to another scirpt that would run the above code. This would all exist on one game object in keeping with the Component Object $$anonymous$$odel.

Something like this:

GameObject SphereCollider Context$$anonymous$$essage $$anonymous$$eyListener DoorActuator

I would attach something like this to the door frame. Then I'd make a script called 'Door' (as I hinted at above) and link that into the DoorActuator script. When the user hits 'f' the $$anonymous$$eyListener would send a message to the DoorActuator calling the 'OpenDoor' method. If you want the door to automatically close after the player leaves the zone then you'd probably want a programmable value for the length of time that the door should stay open after the player leaves the trigger.

Remember to think of each job as a discrete task (a behaviour) that can be added onto any game object that you want.

Let me know if you have any more implementation questions, and I'll be happy to help.

avatar image Joxerbrown · Mar 30, 2014 at 10:38 AM 0
Share

iwaldrop, thanks, i can understand what you are saying, but i have no idea hove to write that code or anything, would you have a link to somewhere that could show me how to write, like something explaining why and how i use what i have to use. I have no experience with doing code.

1 Reply

  • Sort: 
avatar image
0

Answer by Komak57 · Mar 30, 2014 at 11:00 AM

Door should contain a start, and open position which you will lerp/slerp between upon openning or closing. The alternative, is to create an animator for the door to automatically open/close when the value is set. I have door scripts that slerp open when in range, a rigidbody door that opens when pushed, and a chest that opens when [E] is clicked when looked at based on animations. I got what you need.

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 Joxerbrown · Mar 30, 2014 at 12:08 PM 0
Share

$$anonymous$$omak57 as i say i have no experience with script, i have no idea even how to start, i can open monodevelop and paste in someone elses script but no idea how to do my own yet

Follow this Question

Answers Answers and Comments

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

Related Questions

How to make a double sliding door? 1 Answer

[Duplicated Question] Opening multiple doors 0 Answers

open a animated door 3 Answers

Private and public variables 2 Answers

How to Open a Door between two characters at the same time (singleplayer) 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