- Home /
How to toggle off / on raycast on a Gameobject
Hi,
I'm creating an Rpg game with point & click deplacement and top camera. I make this game with uscript.
I try to found a way for disable / enable the raycast on one gameobject.
I know we can do it with the layer "default" and the layer "ignore raycast" but when I do it ingame it make me lag (1 frame / 3 sec).
I tried to toggle off / one the component "mesh collider" of the gameobject but the consol say
uScript: Component 'Mesh Collider' not found on GameObject 'toit_tunnel'.
Ty for any help
Answer by robertbu · Aug 11, 2013 at 07:00 PM
There are different kinds of colliders. I suspect that you are using a build-in game object such as a cube or a sphere. They have box and sphere collider respectively, not a mesh collider. But there is a parent class called 'Collider' for any of the see colliders, and there is a short-cut variable in the GameObject to the collider. So you can do:
gameObject.collider.enabled = false;