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
1
Question by raul corrales · Dec 08, 2010 at 02:34 PM · javascriptmeshcollideractivate

how turn off the mesh collider?

Hi to all...

how turn off the mesh collider? in JAVASCRIPT please

thanks in advance

Comment
Add comment · Show 4
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 Proclyon · Dec 08, 2010 at 02:41 PM 0
Share

It really would not have been a crime to ask two questions in one with http://answers.unity3d.com/questions/30811/how-turn-off-the-mesh-renderer. Since their similarity is so amazing.

avatar image skovacs1 · Dec 08, 2010 at 03:26 PM 0
Share

@Proclyon: Actually, they're quite different. Disabling a renderer is easy, whereas disabling a collider is actually a pain.

avatar image skovacs1 · Dec 08, 2010 at 03:27 PM 0
Share

@raul corrales: please don't shout.

avatar image Proclyon · Dec 08, 2010 at 05:43 PM 0
Share

hah funny, well word count really says just as much as letter similarity in semantics I guess. Thanks for the heads up. Still feels wrong though seeing 2 questions look that much alike piled up.

5 Replies

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

Answer by skovacs1 · Dec 08, 2010 at 03:36 PM

You can't really "turn off" a Collider.

You can them at run-time with Destroy(collider).

You can get the physics engine to ignore collisions with the collider or not, using Physics.IgnoreCollision or Physics.IgnoreLayerCollision.

You can replace the collider with a different collider and perhaps this may serve your purpose.

If you instantiated the object from a prefab without a collider, you could add the collider when you need it and replace the object with the original prefab to remove the collider, copying over whatever settings, positioning, etc. is relevant.

Specifically for MeshColliders, you can specify a mesh to use. By assigning it an empty mesh, it should effectively be disabled. You can then re-enable it by assigning it to be something like GetComponent(MeshFilter).mesh.

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 Eric5h5 · Dec 08, 2010 at 07:05 PM 0
Share

You can remove colliders at runtime by using Destroy.

avatar image skovacs1 · Dec 08, 2010 at 07:23 PM 0
Share

Right, somehow I missed that, having only ever called Destroy(gameObject) or the like. Thanks Eric5h5. Oversight corrected.

avatar image
9

Answer by Linus · Apr 07, 2013 at 06:39 PM

I think that the current answer is outdated.

You can disable a collider at runtime:

http://docs.unity3d.com/Documentation/ScriptReference/Collider-enabled.html

This will disable colliders on objects that have the tag MoveGuide

 for (var obj : GameObject in GameObject.FindGameObjectsWithTag("MoveGuide")){
     
     obj.gameObject.collider.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
avatar image
-1

Answer by danny0_89 · Mar 01, 2017 at 07:24 AM

I use this scrip when the object collides with "Player" it dissapear after 3f and reaperr after 2f

 //Created by Danny0
 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using UnityEngine.SceneManagement;
 
 public class touchdisapear : MonoBehaviour
 {
     public Renderer rend;
     public MeshCollider rend2;
 
     void Start()
     {
         rend = GetComponent<Renderer>();
         rend2 = GetComponent<MeshCollider>();
         rend.enabled = true;
         rend2.enabled = true;
         
     }
     void OnCollisionEnter(Collision col)
     {
         if (col.gameObject.tag == "Player")
         {
             
             StartCoroutine(Time());
         }
     }
         // Update is called once per frame
         void Update()
     {
 
     }
     IEnumerator Time()
     {
         yield return new WaitForSeconds(3f);
         rend.enabled = false;
         rend2.enabled = false;
         
         yield return new WaitForSeconds(5f);
         rend.enabled = true;
         rend2.enabled = true;
        
     }
 }

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 N1warhead · Mar 01, 2017 at 09:22 AM 0
Share

Necro, pay attention to the dates. This was answered years ago. And you're doing it in a completely dumb way.

For one he wanted it in UnityScript not C#. For two - why make things more complicated than it needs to be?

You could have easily just said for C#

 void Start(){
 GetComponent<Collider>().enabled = false;
 }
avatar image
0

Answer by teameden · Jul 26, 2011 at 08:38 AM

gameObject.collider.convex = false;

Is working nice for me, hope that helps.

-TE

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
avatar image
0

Answer by toddisarockstar · Feb 17, 2015 at 03:37 AM

you can simply get rid of it all together with:

 Destroy(gameObject.collider);
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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

BCE0019 "enabled" is not a member of "Object"(On JavaScript Script) 2 Answers

Audio not playing on activation 1 Answer

Run through hastable of objects 1 Answer

Activate and deactivate some script when i press a Key. 2 Answers

Setting Scroll View Width GUILayout 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