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 davidc · Mar 19, 2013 at 01:58 AM · javascriptmesh3d3d model

3d Models, How to turn invisible

Hey Guys, i have a side-scroller game where my character collides with cubes and they turn invisible, i have gotten a 3d model of a Burger and i want to replace the cube with the burger, BUT the way i have gotten the cube to disappear is by coding the visibility of the cubes like this:

GetComponent(MeshRenderer).enabled = false; GetComponent(BoxCollider).enabled = false;

and i cant work out how to make the 3d model disappear because the image is not stored in the (meshrenderer)

Can anyone help, what am i doing wrong?

Comment
Add comment · Show 2
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 ByteSheep · Mar 19, 2013 at 02:18 AM 0
Share

If the burger is a 3d model then it will use the $$anonymous$$eshRenderer component. So your code should still apply to the burger object.. You might get an error if the burger doesn't have a box collider though!

avatar image davidc · Mar 19, 2013 at 02:39 AM 0
Share

I must be importing the model wrong because I just dragged it into the scene and transfered all the data from the cubes to the burger. But the visible part of the burger is not in the mess renderer but is just located in the inspecter at the top of the items field.

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Fattie · Mar 19, 2013 at 07:48 AM

it's just

 renderer.enabled = false;

note that for the collider it's simply

 collider.enabled = false;

this is on a script that's actually attached to the "thing" in question.

As whebert explains it's more likely you simply want to make the object inactive.

 gameObject.SetActive(false);

again this is on a script that's actually attached to the "thing" in question.

If you struggle to get at "other" things ... you want to make "something else" somewhere else inactive or invisible ... then suggest articles on unityGEMS.com for basic beginner help with referring to other game objects, or just read the clear Unity doco "referring to other game objects."

Comment
Add comment · Show 2 · 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 davidc · Mar 19, 2013 at 09:49 AM 0
Share

Thanx, it worked. but i had a audio file attached to the game object and it wouldn't work but i changed the audio file to be on the player and adjusted the script and now it works fine. thanx heaps.

avatar image hafizzizwan2605 · Oct 21, 2017 at 08:35 AM 0
Share

Hi there. can you help me? i'm working with my AR project in unity. I used 3Ds max to develop my 3D object. after i export to AR for Android, my 3D objects become transparent. you know how to fix it?

avatar image
1

Answer by whebert · Mar 19, 2013 at 02:52 AM

If you are using Unity 3.5, you can call

 yourGameObject.SetActiveRecursively(false);

If Unity 4, use the new

 youGameObject.SetActive(false);
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 davidc · Mar 19, 2013 at 03:28 AM 0
Share

The code doesnt seem to work, although do i need to change "yourGameObject" to the objects name? when i did that it said that it could not find "Burger". also there is more then 1 murger in the level, they are kind of collectables. will this code still work for what im wanting to do?

Thankyou so much for taking the time to answer these questions.

avatar image whebert · Mar 19, 2013 at 01:30 PM 1
Share

Sorry, went to bed after submitting the answer, so didn't see your reply till this morning.

Anyway, yes, the "yourGameObject" was only an example - not to be copy/pasted. How you would call SetActive() on the game object depends on where you are calling it from. If you are calling it from a component that is attached to the actual game object you are trying to make invisible, you would simply

 gameObject.SetActive(false);

But if you were calling this method from a script located elsewhere, say a $$anonymous$$anager script perhaps, you would call it on the variable that is a reference to the game object you want to make invisible. Anyway...

avatar image davidc · Mar 19, 2013 at 11:56 PM 0
Share

Thanx allot for your help.

avatar image
0

Answer by davidc · Mar 19, 2013 at 02:39 AM

I must be importing the model wrong because I just dragged it into the scene and transfered all the data from the cubes to the burger. But the visible part of the burger is not in the mess renderer but is just located in the inspecter at the top of the items field.

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

14 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

Related Questions

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer

Drawing a 3D Mesh (javascript) 1 Answer

Scripting Meshes Subdivision(Javascript) 0 Answers

Create edges for vertices(JS) 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