This is a recording from a game called Arcane Reborn.
Question: To toggle the blue filter (a gui frame), how do they detect that your camera is inside the water vs when it's not?
1 messages · Page 1 of 1 (latest)
This is a recording from a game called Arcane Reborn.
Question: To toggle the blue filter (a gui frame), how do they detect that your camera is inside the water vs when it's not?
e
The easiest way to do this is when none of your map is under sea level (e.g. no basements/crevices under it, while not containing water). As then you can just check for the cameras y level, and enable/disable to filter once it's above/below a certain point. Else you will have to actually put up proper terrain detection
oo
if camera.position.y >= waterpart.position.y
remove filter
else
apply filter
?
like that?
and yes all the islands are gonna be above the water
i think that's what u meant
yeah no part of the map except for the stuff under water, is going to be on the levels below/inside the water
You can just have water be at (e.g.) y = 8. then just check for that number, a bit less performance heavy
will bug if i move the water or sumn
leme test this
@jaunty cradle so this is what it looks like right now, i cant tell for sure if there's going to be any problems/if it's going to look weird or anything once i have an actual island
https://gyazo.com/4a90fcb5602b5e036ddf4342816eadcf
leme put ina sample island real quick and increase the water size, i have an old island i made a while back
yeah i think it's gonna be okay, thanks @jaunty cradle
Sorry had to quickly go do something. But yeah, the camera will always be in water once it's lower than that point (as you already stated that all areas lower than it will be water). Anyways, if you change your mind on having nothing below the water than you can always either use raycasts or some exclusion zones (if the camera is in a certain area then it will not be effected by the filter applying below the Y level)
how would the raycast work
i raycast from my camera's position to where?
@jaunty cradle
oh do i just raycast downward and see if it hits water?
I know that it can be a bit buggy, but you can just send a small raycast to right next to it. And if it returns water then it's underwater
I would personally raycast upwards, as then the cam is definitly under the water. But I do remember raycasts not being the best at detecting water, so you will have to do some messing around
Also, of course don't raycast every frame (even though the performance effect is neglictible), just raycasting under a certain Y level is better
Ok
why do you need raycast thats dum
first thing you could do, if its terrain water, is use terrain:readvoxels to determine if the camera's position is in a voxel chunk that is water https://create.roblox.com/docs/reference/engine/classes/Terrain#ReadVoxels. if it's a part for water, you can use either spatial query or any formula for checking if a position is inside a part
no raycast required
I figured a raycast would be more efficient. As I do recall them being one of the more optimised parts of the roblox engine. Yet I could be mistaken