Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Noobfest · Jan 29, 2014 at 07:33 PM · gameobjectphysicsmeshrendererinvisible-object

How can I make a GameObject invisible while maintaining its interractivity?

I've found out the correct answer but I don't know how to use it. I saw that I must write this somewhere: GetComponent(MeshRenderer).enabled = false;

The question is where? Where must I write this?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Jinxology · Jan 29, 2014 at 09:46 PM

You would call that in a MonoScript Component that is on that object. For example, in UnityScript:

 function Start() {
    GetComponent(MeshRenderer).enabled = false;
 }
 

Click Add Component in the inspector on your object to add a new script component, or by using the top Unity menu system.

Read this, it will help you understand the GameObject/Component relationship.

Comment
Add comment · Show 6 · 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 Noobfest · Jan 29, 2014 at 10:34 PM 0
Share

I can't write this (GetComponent($$anonymous$$eshRenderer).enabled = false;) in the new script because it has foreign characters [();.]

avatar image Jinxology · Jan 30, 2014 at 05:51 PM 0
Share

Umm...huh?

avatar image Noobfest · Jan 30, 2014 at 07:03 PM 0
Share

I can only use underscore and letters no other characters

avatar image Jinxology · Jan 30, 2014 at 07:40 PM 0
Share

Sorry, I'm lost as to what your problem is :(

avatar image Noobfest · Jan 30, 2014 at 11:13 PM 0
Share

I want to make a gameobject (cube) invisible while I am still able to interract with it (first person controller collide with the cube while on play mode). To do this I must write this somewhere: GetComponent($$anonymous$$eshRenderer).enabled = false;

You told me to go to the cube's inspector and press "Add component", then write this: GetComponent($$anonymous$$eshRenderer).enabled = false; in the bar above "Component" and click "New Script". The problem is that I can't crate this new script because I can only write letters, numbers and underscore (A-Z, a-z, 0-9, _).

alt text

script.png (9.6 kB)
Show more comments
avatar image
0

Answer by Punkjim420 · Jan 30, 2014 at 11:45 PM

Create a new script and name it something like "MakeInvisible" or "MakeTransparent" then open that script in a text editor like Monodevelop which comes with Unity3D by default. When you open the script in Monodevelop it will have a few premade functions, the first being Function Start() write your code in that function between the {} like this:

Function Start (){ ##Your code goes here## }

if your still lost, i suggest you look at some tutorials, in fact, it might be a good idea to look at them anyways.

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 Noobfest · Jan 31, 2014 at 12:02 AM 0
Share

I did what you said but nothing happened, the cube was still visible. But never $$anonymous$$d $$anonymous$$d now, when I did it it gave me the "All compiler errors have to be fixed before entering play mode!" error when I pressed play. So I openned the project before writting the script but still the same error occured with this written in the console: Assets/Invisibility.js(5,1): BCE0044: expecting EOF, found '}'. (the script was named Invisibility and I know there was something wrong with this character }) but now the script does not exist but it keeps giving me the error.

avatar image Jinxology · Jan 31, 2014 at 01:17 AM 0
Share

Noobfest, honestly, I think you probably need to start with the Unity manual and do some reading to get the basics down: http://docs.unity3d.com/Documentation/$$anonymous$$anual/index.html

Read the basics, learn about GameObjects and Components, etc. I think you are jumping too far ahead based on the dialogue above. You can also go to lynda.com and sign up for a week free, there is an amazing ~11 hour Unity crash course.

avatar image Noobfest · Jan 31, 2014 at 02:57 AM 0
Share

Thanks. I guess I was a bit too excited about unity because I started creating villages, I learned how to use box colliders etc... But I guess I have to be patient and get more advanced on it.

avatar image
0

Answer by raphel john · Oct 02, 2015 at 09:18 AM

@Noobfest try this man

gameObject.GetComponent().enabled=false;

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

22 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

Related Questions

Rubber material 0 Answers

Why are these object passing through each other? 1 Answer

Transform.Position.Y is slowly decreasing but the player is not moving. 0 Answers

Best way to tear apart a piece of paper? 1 Answer

Button Box Door Collision 2 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