Question by
Meh734 · Dec 31, 2017 at 12:18 AM ·
raycastraycastingraycasthit2dlinecast
Linecast ignores obstacles.
Hi.
I'm making it so the AI sends out a ray to check if the player is in front of them, whether it's because I'm tired and I'm doing something whack I'm not sure, but for whatever reason the Linecast goes through all objects, for instance it goes through walls and immediately finds the player. This is not what should happen, it should not find the player because there is an obstacle in the way.
Help would be appreciated.
RaycastHit2D hit = Physics2D.Linecast(GetEyeLocation(), GetEyeLocation() + (dirToTarget * LineOfSightDistance), targetMask);
if (hit.collider != null)
{
Debug.Log("Found player");
}
Comment
Your answer
Follow this Question
Related Questions
Is there any way how to do raycasts like this? 0 Answers
I can't get RayCast to report the collider I want. 1 Answer
Detect when Raycast DOESN'T hit layer. 1 Answer
RayCast2D and RayDraw errors 0 Answers
Select from multiple character to move 0 Answers