How to check if there is any player infront of me without seeing through walls?

So following this topic here: How to check if there are any player infront on me

I figured out how to find any player within my FOV using dotprodcuts, however it lets me see anyone through walls as well. I was wondering how I would make it so it doesn’t register if a wall is infront of me and the person within my FOV?

2 Likes

I would say to use raycasting in such case. However, u can use dot product too.

2 Likes

Could you elaborate? I don’t quite understand

1 Like

Use Dot product to check if a player is in your field of view and then fire a raycast between your HumanoidRootPart and the other player’s HRP. Use RaycastParams and set FilterDescendantInstances to a folder that contains every player character. Then set FilterType to Exclude and if the ray doesnt intersect with any Instance then The player is not behind a wall.

2 Likes

Ah thanks a ton, I don’t use raycasts often so I didn’t know where to start. Thanks!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.