how turn off the mesh collider?

Hi to all...

how turn off the mesh collider? in JAVASCRIPT please

thanks in advance

I think that the current answer is outdated.

You can disable a collider at runtime:

This will disable colliders on objects that have the tag MoveGuide

for (var obj : GameObject in GameObject.FindGameObjectsWithTag("MoveGuide")){
	
	obj.gameObject.collider.enabled = false;
	
}

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`.

gameObject.collider.convex = false;

Is working nice for me, hope that helps.

-TE

you can simply get rid of it all together with:

Destroy(gameObject.collider);

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;
       
    }
}