- Home /
My LayerMask is not working
The spotted bool is not activating with the layer I set it to operate with. It doesn't activate at all when I apply a LayerMask, please help me figure out what is the issue. If you need more info let me know.
public Transform sightStart, sightEnd;
public bool spotted= false;
// Update is called once per frame
void Update () {
Raycasting ();
behaviors ();
}
void Raycasting()
{
Debug.DrawLine (sightStart.position, sightEnd.position, Color.red);
spotted = Physics2D.Linecast (sightStart.position, sightEnd.position, 1 << LayerMask.NameToLayer("Positive"));
}
Comment
Are you sure that what you're linecasting against has a collider?
Yeah everything is set up like it is suppose to. Sorry for the late reply some stuff came up.
Answer by sparkzbarca · Aug 09, 2015 at 03:17 AM
either what you want it to hit doesn't have a collider or what you want it to hit doesn't have the right layer
you'd have to screenshot unity for us.