I’ve searched every corner of the internet to no avail. I’m trying to get a script that can detect if the player camera is underwater, and will take into account waves. Using getvoxels or getcells won’t work because it doesn’t take into account waves and is not accurate.
This isn’t impossible, it has been done before.
This is a great example of what I need to achieve. This game takes into account waves, and I don’t know how it works but I want to.
I have had some progress, via help from this thread, but haven’t figured out how to fully implement this equation. A number of problems occur. Firstly it seems I have to make the waterwavespeed 0 for it to work, secondly, it only works in a small area, and only in a specific Y position. I’d like it to work anywhere everywhere with water. Please don’t reply in the comments with compromises, because I’d like it to work fully and accurately.
Alright, so I’ve made a rough map of where it works, and it seems to only work in one direction and only in this small rectangle of space. Additionally, I am unable to make the water move because if I do, it will cease to function
Also from what I know, I dont think its possible to exactly detect the waves from which the water is acted upon. You’d either have to make your own wavy water or deal with the odd glitchiness that comes with it sometimes .
The wave effect doesn’t effect anything and is only meant for viewing pleasure meaning it isnt possible (as I know right now though I may be wrong) to detect.
I tested out the game, and unsurprisingly (seeing as the post was from 2016), didn’t at all take into account waves. Again, I’d highly encourage you (and anyone else posting) to thoroughly read my post
I took a look at the thread and it seems that the guy who found out the math said this
It takes approximately 8.4 seconds to complete a full cycle at WaveSpeed 10
Oh, btw this is for when the WaveSize property of Terrain is set to 1
It looks like you just used the equation as is. It will only work on that y level because there is no other position being added to it. Try doing it again but after the equation, add the player’s position or camera position.
How will I do that? I’m so stumped. The thread you linked I just found out the guy said it only works with static water. Do I add a wait the speed a water completes a full cycle? If so, then it would not work for that wait! Help me!
It looks like you just used the equation as is. It will only work on that y level because there is no other position being added to it. Try doing it again but after the equation, add the player’s position or camera position.
I think something very important to note is that place you linked isn’t doing what you think it’s doing.
Try visiting it again and really watching the water. I was perplexed, at first, by how accurate-seeming the underwater sound effect was.
But then I started looking a bit closer and realized… there’s no wave height. There’s no waves at all. What is giving you this “imaginary” effect is that animation of the character. The character itself is bobbing up and down which causes your camera to move in a “wave.”
The creator is simply checking if you’re under the surface of the water or not - as there are no actual waves - by determining if the center of the camera is submerged by about half.
With the image that you have provided, it looks like you just used the equation as is, which happens to be y = 1.8 * sin(2pi/85 * x) * sin(2pi/85 * z)
I was trying to say instead of using just that, you can change the y value based on the player’s position. An example would be:
waveEQ = 1.8 * math.sin(2 * math.pi/85 * x) * math.sin(2 * math.pi/85 * z)
y = waveEQ + camera.Position -- could either be player or camera position depending on the scenario.
Actually, there is. Try running the game and go on the surface of water. Don’t move your camera and let it stay there. The waves actually do move and it’s not (just) bobbing.