Physics ignore layer collision script error

Hi - sorry this is very simple (I know there’s lots of similar questions on the forums but I can’t find one that works)

I just need my collider to ignore all collisions from layer 8.

This is the script I wrote (JavaScript):

var layer8 : int;
var ignore : boolean = true;



function Update () {

Physics.IgnoreLayerCollision(layer8, true);

}

But I get the error BCE0023: No appropriate version of ‘UnityEngine.Physics.IgnoreLayerCollision’ for the argument list ‘(int, boolean)’ was found.

Do you know what I’m doing wrong?

Thanks, Laurien

Hi

the Physics.IngoreLayerCollision()-Method is used to disable collision between two layers.
With your code, the Physics engine don’t know which objects should be ignored for collision with layer8.

try

Physics.IgnoreLayerCollision (layer8, otherLayer);

you probably want to do this for all the layers that you want to be ignored

Physics.IgnoreLayerCollision (layer8, layerOne);
Physics.IgnoreLayerCollision (layer8, layerTwo);
Physics.IgnoreLayerCollision (layer8, layerThree);

If you never need collision with layer8 you can just remove the Collider-components from the GameObjects on layer8.

PS - the error you get is because you try to pass inappropriate parameters to the function. So when coding you can type Physics.IngnoreLayerCollision and as soon as you type the bracket there will be anpther popup (tooltip) that shows you all the overloads for this method and its parameters. This can help you to avoid errors like this.

I hope this is what you are looking for.

The Physics.IgnoreLayerCollision function receive as params int named layer1, another int named layer2, and a boolean called ignore

this is the function :

Physics.IgnoreLayerCollision(int layer1, int layer2, bool ignore);

You’re forgetting the second param, layer2.

Use integer in Physics.IgnoreLayerCollision(8, 10);
u need integer not like that (layer8, layer10);