Hello,
Did unity have a way to disable collider via script?
Something like this:
MeshCollider.enabled = False;
I´d like it stops trigger events when someone click on the mesh
Hello,
Did unity have a way to disable collider via script?
Something like this:
MeshCollider.enabled = False;
I´d like it stops trigger events when someone click on the mesh
You can’t disable a collider, but you can destroy it. Alternately, have a variable which can be true or false, and skip the trigger events if it’s set to true.
–Eric
Thanks for the help, but isnt working yet…
it still triggering mouse clicks and rollovers.
What i want is the objects disapear and cant be clicked, but can be called again.
i try it by 2 ways:
if (n==“1”){
renderer.enabled = true;
collider.isTrigger = false;
}
if (n==“0”){
renderer.enabled = false;
collider.isTrigger = true;
}
}
or
if (n==“1”){
gameObject.active = true;
}
if (n==“0”){
gameObject.active = false;
}
}
this second way works, but it not activate the object when you set the n=1 again, like it was destroyed, and i dont understand why…
i already solved the problem…
the script
gamobject.active=true;
isnt workng becuase the object is inactive, and if it was inactive it cant read scripts…
i solve it inserting the code on the button
its hard to be a newbie