Search Unity

detecting player

Discussion in 'Scripting' started by KhmerDude, Jan 16, 2016.

  1. KhmerDude

    KhmerDude

    Joined:
    Oct 18, 2012
    Posts:
    105
    Hi, Im trying to use Physic2D.Linecast to detect player and I was just wondering if I were to attach this to my game background, would this help with performance

    Code (CSharp):
    1. playerIsHere = Physics2D.Linecast(alertStart.position, alertEnd.position, 1 <<LayerMask.NameToLayer("ThePlayer"));
    2.         if(playerIsHere){
    3.             renderer.enabled = true;
    4.             Invoke("KillBackground", 6f);
    5.         }