How do I, detect if a part is off screen, partly or mostly behind a wall (still showing), or fully behind a wall? (not showing) [REPOST]

I have a few questions about the WorldtoViewportPoint function, that I don’t know how to fix.

  1. How do I detect if a part is off screen? (the part is behind you) [damage will not be taken] {Unsolved}

    .
  2. How do I detect if a part is partly behind a wall? (still showing slightly) [damage will still be taken] {Unsolved}

    .
  3. 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.

Green Checkmark 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 new BrickColor called PartColor , then you can use that and WorldToViewportPoint to get the X and Y of the part in question. If both the X and Y are between 0 and 1 (inclusive), then the part is visible. If both are outside this range, then the part is not visible.

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 new BrickColor called PartColor, then you can use that and WorldToViewportPoint to get the X and Y of the part in question. If both the X and Y are between 0 and 1 (inclusive), then the part is visible. If both are outside this range, then the part is not visible.

Can you please explain this? I don’t fully understand.