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:
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?
If the burger is a 3d model then it will use the MeshRenderer 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!
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.
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.
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.”
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.
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?
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.
If the burger is a 3d model then it will use the MeshRenderer 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!
– ByteSheepI 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.
– davidc