Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Nolukdi · Sep 02, 2017 at 04:53 AM · colliderbuttontriggerbuttonstriggers

How do I make a button appear when my player enters a trigger?

Okay, here's my issue. I have a 3D sidescroller set up with a nice player and a camera that follows him all coded in C#. In this particular sidescroller, I will be giving the opportunity for choices! Yay, right?...Wrong. When my player enters the trigger I have set for the choices, nothing shows up. The buttons are there, but they do not show up in the game view or when test playing. It is VERY frustrating. I have used this particular script before to do a jumpscare, and it has worked, however the buttons simply refuse to show up. Any help would be appreciated. Thank you :) Here is the script:

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class JumpScare : MonoBehaviour {

 public GameObject jumpscareObject;

 void Start () {

     jumpscareObject.SetActive (false);

 }

 void OnTriggerEnter (Collider player) {
     if (player.tag == "Player") {
         jumpscareObject.SetActive (true);
         StartCoroutine (DestroyObject ());
     }
 }
 IEnumerator DestroyObject()
 {
     yield return new WaitForSeconds (5f);
     Destroy (jumpscareObject);
     Destroy (gameObject);
 }

}

P.S. If anyone could also help with another goal I have that I can't seem to figure out, how would I get these buttons to go away upon clicking them?

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

· Add your reply
  • Sort: 
avatar image
1

Answer by DayMoniakk · Sep 02, 2017 at 11:50 AM

Hello, your buttons are separated in another canvas ? If yes, you have to put this canvas order to the foreground by changing the sort order value. alt text

Let me know if its worked.


screenshot-3.jpg (54.9 kB)
Comment
Add comment · Show 3 · 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 Nolukdi · Sep 03, 2017 at 01:22 AM 0
Share

thank you for replying so quickly. Both of my buttons are in the same canvas, but I figured it out anyway! I needed to change the render mode on the canvas to "world view" so that the main camera could see it. If you're still ready to help, I haven't gotten word on the other question: how to make the buttons disappear after clicking on one of them?

(I'd imagine I'd just make the canvas disappear as one of the button's functions but I'm just not sure how to do that)

avatar image DayMoniakk · Sep 03, 2017 at 10:30 AM 1
Share

I think you can simply do this :

 public class HideButton : $$anonymous$$onoBehaviour 
 {
     public GameObject Button;
 
     public void ButtonDisappear ()
     {
         //Put in this line what your button is doing
         Button.SetActive(false);
     }
 }

You add the button in the inspector window : http://image.noelshack.com/fichiers/2017/35/7/1504434513-1.jpg (for some reasons I can't import screenshots)

And you set the "OnClick ()" of the button in the inspector window : http://image.noelshack.com/fichiers/2017/35/7/1504434518-2.jpg

It's not the best way to do this but it's stay simple

avatar image Nolukdi DayMoniakk · Sep 04, 2017 at 03:11 AM 0
Share

You're a saint! Thank you so much!

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

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

Related Questions

Does OnTriggerStay ignore layers? 1 Answer

Translate Jump Trigger Collision Issue 1 Answer

changing gravity OnTriggerEnter 1 Answer

How to Specify a Collider in OnTriggerStay function? 1 Answer

Simple Triggers problem. 1 Answer


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