- Home /
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
Answer by InfiniBuzz · Jun 10, 2013 at 12:21 AM
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.
Thanks - I understand how it works now. (I need to keep the colliders because they've got another function) - but it's working now - thanks again :)
Answer by Mukabr · Jun 10, 2013 at 12:19 AM
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.
Answer by diverseer · Jan 19, 2017 at 09:03 PM
Use integer in Physics.IgnoreLayerCollision(8, 10); u need integer not like that (layer8, layer10);
Your answer
Follow this Question
Related Questions
How to achieve this basic physics effect? Detect when to change layers 2 Answers
Does the "Layer Collision Matrix" affect triggers? 1 Answer
Layer Collision in Networks (Mulitplayer Game). 0 Answers
Button to change layers 1 Answer
Layers are colliding even though they are set to ignore each other 1 Answer