Neede a collider to stop interrupting raycasts immediately

I wish I could give more details about the background of the situation, but it’s very complicated. Long story short: I need some way - any way - to get a gameobject’s collider to stop responding to raycasts immediately. Destroying the object obviously doesn’t take effect until the end of the frame. Near as I can tell, however, neither does changing the GO’s layer or destroying the collider?

Is there any way to force it to update instantly?

DestroyImmediate, on the other hand, lives up to its name quite well.

–Eric

I was under the impression that you should only use that in editor scripts?

In one of my scripts, I change the layer, do a raycast, then immediately change it back again. This is all in a Start function without the use of yield. It works fine for me.

In your case, StarManta, it would probably be easiest to set the layer of the object you’re going to destroy to “Ignore Raycast”. Then your other raycasts will ignore it if they aren’t explicitly using layer masks.

I used it once when I needed to get rid of a collider on an object right away and not wait the one frame that Destroy needs, since even that one frame caused a physics reaction that I didn’t want. It worked fine though obviously you have to be more careful, and that was the only time I’ve ever used it.

–Eric