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 Gintas.S · Dec 19, 2015 at 08:11 AM · collisionrenderersetactivemeshrendererappear

How to make an object appear after collision with an invisible object. I have tried a lot of ways, but still failed please help!

I have tried all of these ways, but still failed. I also tried setActive, but I just get errors using that. Please help I really need to understand this as I have multiple things I need to make appear after one another. Also the object I'm adding this script to is a fps controller. Side note the object LT_Birute_v1 is a solid and the object birutedialog is an invisble object, these codes I tried don't work with either. Sorry I'm really new at this. http://imgur.com/a/lVBTN This link will provide pictures with some clarification.

     using UnityEngine;
     using System.Collections;

     public class appear : MonoBehaviour {
     public GameObject myGameObject;

     void OnCollisionEnter (Collision col)
     {
         if(col.gameObject.name == "birutedialog")
         {
         myGameObject.GetComponent<MeshRenderer>().enabled = true;
         myGameObject.GetComponent<Renderer>().enabled = true;

         }
     if(col.gameObject.name == "LT_Birute_v1")
     {
         myGameObject.GetComponent<MeshRenderer>().enabled = true;
         myGameObject.GetComponent<Renderer>().enabled = true;

     }
     }
 }
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
Best Answer

Answer by allenallenallen · Dec 19, 2015 at 08:16 AM

What is myGameObject? It's the only thing you are making visible here. And it seems like it has nothing to do with either biruteddialog or LT_Birute_v1

What exactly are you trying to do here? You said you wanted an object to appear after colliding with an invisible object, right? Does that mean both objects are invisible?

If anything, all you need to do is set the GameObject of the one you want to appear to enable renderer after collision.

When you write this line:

 myGameObject.GetComponent<MeshRenderer>().enabled = true;

You are making the GameObject myGameObject MeshRenderer to be enabled. But only you know what that GameObject is, because you set it up in the editor.

Comment
Add comment · Show 8 · 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 Gintas.S · Dec 19, 2015 at 12:22 PM 0
Share

I will upload a few pictures on imgur to help me explain it. Sorry for not being specific.

avatar image Gintas.S · Dec 19, 2015 at 12:40 PM 0
Share

http://imgur.com/a/lVBTN Here is a link to some pictures for clarity.

avatar image allenallenallen Gintas.S · Dec 19, 2015 at 12:47 PM 1
Share

Ah, I see. Everything's clear now.

 if (col.gameObject.name == "birutedialog" || col.gameObject.name == "LT_Birute_v1")
 {
     myGameObject.GetComponent<Renderer>().enabled = true;
 }

That should be all you need then.

avatar image Gintas.S allenallenallen · Dec 19, 2015 at 01:06 PM 0
Share

For some reason it still does not work. Could I maybe please take a little bit of your time and ask you to make a few pictures where this code is used in action? Or maybe I can watch a video tutorial or something about it. Sorry for all of this asking for things...

Show more comments
Show more comments
avatar image allenallenallen Gintas.S · Dec 19, 2015 at 01:47 PM 1
Share

Pretty much the same thing.

 void OnTriggerEnter(Collider col)
 {
      if (col.gameObject.name == "birutedialog" || col.gameObject.name == "LT_Birute_v1")
      {
          myGameObject.GetComponent<Renderer>().enabled = true;
      }
 }

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

SetActive messes up everything? 1 Answer

Changing gameobject material via mouse click not working 1 Answer

How to make work a collision when is invisible? 3 Answers

How to change the material color of an Instatiated prefab when the player enters the collision area and presses a button? 0 Answers

Unable to disable collider2d and renderer of gameobject. 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