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 Theft4Bread · Nov 12, 2012 at 12:25 PM · buttontriggerpress

Changing the sliding door script in Angry Bots to open at a button press.

Hello, I'm very new to Unity and have a quick question to ask. I am making a level for a class I am taking at college that requires me to make a level using the assets from Angry Bots. The problem I have is that I have 0 scripting experience and need to change the sliding door to open at a button press rather than a proximity trigger. Here is what the code looks like now:

 #pragma strict
 
 public var enterSignals : SignalSender;
 public var exitSignals : SignalSender;
 
 public var objects : System.Collections.Generic.List.<GameObject>;
 
 function Awake () {
     objects = new System.Collections.Generic.List.<GameObject> ();
     enabled = false;
 }
 
 function OnTriggerEnter (other : Collider) {
     if (other.isTrigger)
         return;
     
     var wasEmpty : boolean = (objects.Count == 0);
     
     objects.Add (other.gameObject);
     
     if (wasEmpty) {
         enterSignals.SendSignals (this);
         enabled = true;
     }
 }
 
 function OnTriggerExit (other : Collider) {
     if (other.isTrigger)
         return;
     
     if (objects.Contains (other.gameObject))
         objects.Remove (other.gameObject);
     
     if (objects.Count == 0) {
         exitSignals.SendSignals (this);
         enabled = false;
     }
 }
 


Any help is greatly appreciated!

Comment
Add comment · Show 3
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 fafase · Nov 12, 2012 at 12:48 PM 0
Share

$$anonymous$$eep the trigger principle but ins$$anonymous$$d of automatically opening the door (I actually do not really see where it happens in what you posted...), then you just need to add an

  if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))//opening section.

So the idea is: Am inside the trigger box? Yes. Then am I pressing the button? Yes. Open the door.

If the door opens , you are only missing the input part.

avatar image Theft4Bread · Nov 14, 2012 at 02:54 PM 0
Share

I really appreciate your help with this, but I have no idea where to put that in the code-like I said I have zero scripting experience.

avatar image fafase · Nov 14, 2012 at 03:46 PM 0
Share

I am sorry to say but you need to learn first. The only solution here is to give you the code but you wouldn't get anything out of it. If you do not know program$$anonymous$$g, you will never get out of the mud. Get any program$$anonymous$$g books, I would recommend to start with C as it is the first one, but you could skip and dive in C# right on. If you know program$$anonymous$$g but not in Unity then start some tutorials, the web is filled with them.

0 Replies

· Add your reply
  • Sort: 

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

10 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

Related Questions

How to configure Gui Buttons and trigger2D correctly? 1 Answer

Button back not clickable after rotation animation 1 Answer

How To play sound with a keypress 2 Answers

How to make animations on button press. 2 Answers

Button Press and Hold Animations 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