How to detect if player see this object and when player see the object, something will happen.
I’m not sure if that is even possible, I could be wrong though.
like x-ray?
No,Just if player look at block then fire function
You can fire a ray from the players head or humanoid root part and any object it hits, the player is able to see.
Tell me how please and thank for respond
Here is the API documentation to get you started.
If you don’t understand it, you may want to use this tutorial on making a laser gun but alter it to your character.
i mean if you look at this object, it will say like print(“you look at this object”)
Personally the way I’d do it is to get the angle between the player’s head, and the object’s position.
If the angle is less than 60 degrees, you proceed to create a ray from the player’s head, to the object’s position.
If the ray hits the object, it’s safe assume that the player can see it.
Alternatively, I’d probably use WorldToViewportPoint since the second returned item in the tuple is a boolean indicating if the WorldPoint is in the Viewport.