- Home /
How to detect if under Water (Pro Version with the waves)
Hi Guys,
I Currently Have this script that detects weather i'm under water by checking my cameras transform.position.y against the water level, but the issue is that with the PRO Version of Water, there are waves, that change the level, is their a way to detect in real time, what the level of the water is? so that even when my player/capsole is in same place, but the waves get higher than the camera, i can run my code for water effects?
Cheers.
Answer by PeterB · Nov 13, 2013 at 04:36 PM
There is no accessor in Water4 for the effective water surface height. There was one in Water3, but Water4 has none. On the whole, Unity haven't given Water4 much love in ages.
Answer by Itinerant · Oct 18, 2012 at 03:51 PM
From my understanding, there's not actually any wave mesh that's changing shape. Pro water is a flat surface, waves and reflections are just animated textures on the surface. They render to look 3d, but when you get really close they're flat. You can test this yourself by placing a camera just above the surface of the water and watching it run.
Unless you have a different pro water than what I'm using, there are no waves to fight against :)
Hi Itinerant, I'm definately using a deffirent type of Pro water as i have dynamic mesh that has waves during run time, and when my player is half in the water, the waves will do over and under the camera.
Ah, did a bit more looking. Are you using the Water4Example that's included with the standard pro assets?
Hmm, I can't help out with that, unfortunately :/ I imagine you'll have to dig into the code of the displacement scripts, as it doesn't appear that the mesh and any associated colliders are being deformed. That's beyond me, so I'll just wish you luck :)
yeah, i noticed that the actual tiles for the water weren't being deformed so i could not do a colider check, i'm still looking into the code. thanks anyway.
Answer by moinchdog · Jan 05, 2013 at 11:47 PM
i got this working where i put the level the camera thinks its underwater about 0.5-1 above the actual water. If your going in slowly you might catch a glimpse of underwater effects above its really brief and hard to notice. Hope this helps
Your answer
Follow this Question
Related Questions
Unity 5 light reflection on the water surface 0 Answers
"Pro" Water turns an ugly gray in distance 0 Answers
Water is flat in Unity 5 2 Answers
Unity 5: Water4 4 Answers
Deep Water Problem 0 Answers