I have a few questions about the WorldtoViewportPoint
function, that I don’t know how to fix.
- How do I detect if a part is off screen? (the part is behind you) [damage will not be taken] {Unsolved}
. - How do I detect if a part is partly behind a wall? (still showing slightly) [damage will still be taken] {Unsolved}
. - How do I detect if a part is fully behind a wall? (not showing at all) [damage will not be taken] {Solved}
I don’t think Raycasting would work, because there are parts behind my part in question.
Question 3 solved by xDeltaXen in post #2
I don’t think Raycasting would work, because there are parts behind my part in question.
Raycasting would work for this. If you want to be extra sure, you can raycast from the camera to the part in question, and then from the part in question to the camera. If the raycast from the camera to the part in question detects a part before it gets to the part in question, then that means the part in question is obscured from view.
However, you can also use a better method. If you create a newBrickColor
calledPartColor
, then you can use that andWorldToViewportPoint
to get theX
andY
of the part in question. If both theX
andY
are between0
and1
(inclusive), then the part is visible. If both are outside this range, then the part is not visible.