Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How would I detect if the player can see an object?

Asked by 4 years ago
Edited 4 years ago

I’m trying to make a horror game and I want to detect if the player can see the monster. How would I do this? Any help would be very appreciated!

0
One way is, RAYCASTING!!! BashGuy10 384 — 4y
0
@BashGuy10, can you explain how to do raycasting in an answer? ultramansonicspeedxD 5 — 4y
0
Try raycasting, it really helps. I don't know much about raycasting but search some up, i'll make some if you can't find the right tutorial! diorlandripp 4 — 4y

1 answer

Log in to vote
0
Answered by
ryan32t 306 Moderation Voter
4 years ago

It's possible. I already made the script because I wanted to know how to do this and someone had a similar Question.

Research WorldToScreenPoint() and GetPartsObscuringTarget()

WorldToScreenPoint() -- This can tell you if a Part is visible(even through walls)

GetPartsObscuringTarget() -- This gives you a Table containing all the parts that is intersecting two given points

If you do it right then you can detect if the monster is in the player's screen. Unless if you want to know if the player is looking directly at the monster then use RayCasting or mouse.Target

Ad

Answer this question