Detect Player Camera Enters Trigger

Hi, im trying to detect player camera enters box collider to toggle Underwater Screen Space Shader.
I managed to detect player enters trigger, but it was not suitable for my purpose.

How can i track the player camera(or viewpoint) and detect it entering or exiting the trigger?

Thanks in advance and sorry for my bad english skills.

1 Like

You can use the player’s tracking data to get their head position in World Space, then check that that position is inside the trigger’s bounds.
You can put this code within a OnPlayerTriggerStay() event

Vector3 playerHeadPos = _localPlayer.GetTrackingData(VRCPlayerApi.TrackingDataType.Head).position;
if (collider.bounds.Contains(playerHeadPos)) { underWater = true; }

I only have the U# code on hand at the moment. If you need an Udon Graph example, let me know.


Im not sure if I did it right, but it worked perfectly.
tell me if i did something wrong, and Thanks very much