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 ditchmaster · Apr 19, 2012 at 08:41 PM · triggerobjectcontrollerdoor

How to trigger a door with an object not first person controller

Hello! I am very new to Unity and scripting, but I'm trying to make a game where the player finds an object and picks it up. The player then goes to a door (carrying the object) and the object triggers the door to open to finish the level. My problem is that I cannot figure out how to get the object to trigger the door open. I tried several different scripts, but only one of them worked and I'm too new to be able to fix the other ones. The one that worked is perfect, except that not only the object triggers the door but the first person controller, which means that at any point the player can walk up to the door and win the game, which defeats the purpose of playing it. Can anyone help me figure out a way to solve this problem?

Thanks!

Comment
Add comment · Show 1
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 Explosives1161 · Apr 19, 2012 at 08:48 PM 0
Share

Have you tried to creat a boolean variable that =false, then when you get the object that opens the door, make the variable true? Then you could probobly make a script code that says that if you come in contact with the door and the boolean variable = true then open the door. Im not sure if it could work or not but you could do something like that.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Piflik · Apr 19, 2012 at 08:51 PM

Add a unique tag to the object (example 'Key'), add a trigger to both the key and the door and then add a script to the door:

 function OnTriggerEnter(item) {
     if(item.tag == "Key")
         OpenDoor();    
 }

You have to either declare a OpenDoor() function, o replace OpenDoor() with whatever code you use, to actually open the door.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Presure plate that triggers an animation 1 Answer

Creating objects when entering a trigger? 1 Answer

Putting an object somewhere to destroy something else 1 Answer

Object detection in front of Character 1 Answer

What's the best way to check if an area is empty? 7 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