Home Game Development unity – My enemy Raycast is bypassing partitions and is ready to see participant

unity – My enemy Raycast is bypassing partitions and is ready to see participant

0
unity – My enemy Raycast is bypassing partitions and is ready to see participant

[ad_1]

My raycast is ready to bypass the partitions and enemy is ready to see the participant. How am i able to make my ray to not go the partitions . I do not wish to use linecast. enter image description here

Here is my code

Vector2 finalPosition = new Vector2(directionOfRay, 0);

    RaycastHit2D raycastHit2D = Physics2D.Raycast(enemyEyes.rework.place, finalPosition, finalPosition.magnitude , LayerMask.GetMask("Player")   );
    

       if(raycastHit2D.collider != null )
        {
           if (raycastHit2D.collider.gameObject.tag=="Player")
            {
                Debug.Log("Hit Hit");
            }

        } 

This code remains to be printing Hit Hit even my participant is behind the partitions and this ray is ready to bypass the partitions

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here