Region3 Inconsistency

I have made a system that blurd your screen when your camera enters custom water.

I made this by doing a region3 check at the current camera position every frame.

Sometimes, the region doesnt detect the water even though it should.

Example:

As easy as it sounds, Ive had a tough time trying to fix it with no success.

1 Like

It’s hard to offer any advice without the code. :grimacing:

Ahh, I’m on my phone and I cant access it sadly, but i remember exactly what it does:

  1. every render step it creates a region3 at the camera’s cframe position
  2. i do a workspace region3 check with whitelist for everything that is tagged “Water” by collection service, the region’s size is 0.1 studs by the way
  3. if there is water, then if the effects arent off, it turns them on, if there isnt water and effects are on, it turns them off.
    As simple as that.

I think it’d be a better option to create a part, set its size to the size of the character model using :GetExtentsSize(), weld that part to the player’s root part so it’s about center and covers the whole character model, then create a region3 around that part and determine if any water parts are in the region cast around that part.

Hope it helps :slight_smile:

EDIT
Just realized this could cause problems with consistency depending on the rotation. To bypass this, instead of welding, you could manually set the CFrame of the part to the position of the player’s root part so the part doesn’t rotate with the character. The part may need to be slightly larger than the extents size so it fully covers the player’s character depending on which direction they turn. You can update the CFrame of the part each frame so it’s accurate with the player’s current position in the game world.

1 Like

But I don’t need to get the position of the root part. I’m trying to see if there’s any water inside the camera.

Have you tried raycasting from the camera’s origin with a direction of its LookVector??

Might yield better results

Raycasts don’t work if they start and end inside the same part, do they?

I wouldn’t think that matters? I haven’t tried personally, but it should work.

You can also define a whitelist table of instances to ignore for the ray.