I have a Pickup script attached to a simple object, this scripts make this object to rotate and oscillate, and ofcourse, if you hit it with your player, it disapears and become invisible thanks to 'renderer.enable = false'.
I need to say that this object ( a simple sphere ) have a sphere collider with 'isTrigger' option enabled, so when you hit it with player, OnTriggerEnter() is executed.
The main problem is when the renderer is disabled, collisions seems to stay up and active, and may camera's raycasts still found an spherical collider in this position. I repeat, sphere collider have 'isTrigger' enabled, but raycast still found a collider to collide with.
I tryed to disable the collider component with 'collider.active=false', but then, Pickup script is halt and no more calls to Pickup Update() function are made anymore, and ofcourse, i can't control how many time has been past to make the pickup visible again.
How can i disable this sphere collision wihtout shutting down Pickup's script ?
Thanks for your time :)
asked Jan 12 '10 at 04:52 PM
Llorens Marti Garcia
just put it in a layer and use layermasks while doing raycasts. if you put the object in ignore raycast layer it will be done automatically for you in OnTriggerEnter event where you disable the rendering put a code like this
this code will get the current layer and stores it in a variable and then change the layer to "ignore raycast" layer. you should define the variable l as a private variable in class scope in C# or outside your functions in js. then when you want to make the pickup visible and enable ray casting put a code like this.
take a look at reference for layers and LayerMask classes and raycast functions to get more info.
answered Jan 12 '10 at 05:17 PM