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
2
Question by usman_the_great · Jul 20, 2010 at 03:36 PM · collisioninvisible

How to make objects invisible on collision?

Original title: can someone make a script on it in java

i want to know the script which do this thing

if body1 touches body2 than body1.visible=false

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 jashan · Jul 20, 2010 at 04:05 PM 0
Share

I've changed the title to be useful for someone looking for a solution to the same problem and added the relevant tags. I won't write the code for you but in the answer, you're getting everything you need to write the code for yourself, which ... btw ... will be much more rewarding than copy'n'pasting someone else's code ;-)

avatar image usman_the_great · Jul 20, 2010 at 05:15 PM 0
Share

Thanks for changing the title

2 Replies

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

Answer by jashan · Jul 20, 2010 at 03:58 PM

A) There is no Java in Unity. There is, however, JavaScript also referred to as UnityScript. JavaScript has nothing to do with Java ;-)

B) What you are looking for is this:

  • MonoBehaviour.OnCollisionEnter or MonoBehaviour.OnTriggerEnter, the documentation includes nice examples to get you started
  • One way to make an object invisible is using renderer (a property of any MonoBehaviour) and enabled (also a property of any MonoBehaviour - but this, in particular, is enabled of Renderer which has the semantics that when it's switched to false, it makes the object invisible)
  • And, of course, you need a basic understanding of Physics; watch out: you're probably wanting to use triggers. In particular, you'll want to understand the Collision action matrix (it's one section in that part of the documentation)

C) If you need to learn programming, you could try one of the tutorials, e.g. start with this answer: How to get started learning JavaScript or UnityScript?

Comment
Add comment · Show 5 · 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 usman_the_great · Jul 20, 2010 at 05:17 PM 0
Share

i want to invisible that object which i want

avatar image usman_the_great · Jul 20, 2010 at 05:19 PM 0
Share

i learnt the basics of the java

avatar image jashan · Jul 20, 2010 at 05:26 PM 0
Share

As I've written in my answer, under B - you can user render.enabled = false to make the object invisible. The renderer makes the object visible - and when the renderer is disabled, the object is invisible. $$anonymous$$ight not be totally intuitive if you're just starting but makes a lot of sense if you have a bit of a deeper understanding of how Unity uses game objects and components.

Regarding the "basics of java": There is no Java in Unity. If you know Java (the program$$anonymous$$g language and framework developed by Sun $$anonymous$$icrosystems), I recommend learning C# because it's very similar to Java.

avatar image usman_the_great · Jul 20, 2010 at 06:19 PM 0
Share

now i know that how i do it by using trigger

avatar image jashan · Jul 20, 2010 at 07:16 PM 0
Share

Great ... if you feel the answer is valuable and correct, you may consider "accepting" it by clicking on the little "check" icon next to the "score" (which currently says "3"). That will help people see that the question has an accepted answer.

avatar image
0

Answer by Panamamigo · Jul 20, 2010 at 04:28 PM

why don't you just set the renderer.enabled= false;? That will make Unity forget about rendering that object and it will be invisible, un-interactive, un-responisve, etc. It'll be like it never existed until you reset the renderer.enabled to true again. So write the code, but if what I illustrated is what you are looking for then you at least have a hint of where to start.

Comment
Add comment · Show 1 · 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 Mike 3 · Jul 20, 2010 at 05:09 PM 0
Share

It'll still be interactive, responsive, and whatever else. It just stops rendering it is all, the collider and scripts will still work the same

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

No one has followed this question yet.

Related Questions

How to enable/disable "Is Trigger" on collision enter ? 3 Answers

Makeing something Blow-up 3 Answers

Renderer on object disabled after level reload 1 Answer

can someone come up with a script that makes a game object explode and destroy itself on impact with the first person controller 2 Answers

Cube on a plane - ball moves slowly twds it and goes through it?!?! 4 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