make the line cast completely ignore a layer

can someone explain me this in coding?.. because when people tell me in pratical terms i just cant imagine how would look like in javascript…

heres my code so far :

if (!Physics.Linecast (transform.position, target.position)) {

[COLOR="seagreen"]// detected there is not a direct line between the target and the linecaster..[/COLOR]

}

now… how do i implement a exception to this case?.. i want a certain object to be between the linecaster and the target, and even so this script does not notice it

can someone gimme a example? i’ll be very thankfull

1 Like

i’ll take anything… other solutions … or a way to ignore layer instead of a tag

Hi there!

What you need is a layermask for when you perform the linecast. This is how it looks in code:

var mask : int = 1 << 9;
mask = ~mask;
if (!Physics.Linecast (transform.position, target.position, mask)) {
}

With this mask you will ignore layer 9. So change the 9 to whatever number your layer has.

1 Like

you rock! you’re the man!

Usually easier to use

var mask : LayerMask;

and use “mask.value” in the linecast.

–Eric

2 Likes