- Home /
Underwater effect?
Is it possible to do an underwater effect for Unity iPhone? By this I don't mean fog but rather the wavey kind of ripply lines that you get underwater to make everything look more organic. If there is then could someone point me in the right direction?
Thanks in advance!
@RO$$anonymous$$ this might help- https://medium.com/@mukulkhanna/creating-basic-underwater-effects-in-unity-9a9400bde928
Answer by JJAPrograms · Mar 10, 2011 at 05:43 PM
Try using this code:
//set your varibles here.
var fog = false;
var fogColor = Color (0, 0.4, 0.7, 0.6);
var fogDensity = 0.04;
var skybox : Material;
//this is where you go underneath the water or in this case into the trigger aera
//this is just the effect not anything to do with force.
function OnTriggerEnter(other : Collider) {
fog = true;
RenderSettings.fog = fog;
RenderSettings.fogColor = fogColor;
RenderSettings.fogDensity = fogDensity;
RenderSettings.skybox = skybox;
}
//this is where we are exiting the water and the effect of being underneath the water is ended.
function OnTriggerExit(){
fog = false;
RenderSettings.fog = fog;
}
Hope it helps!
Answer by Goody! · Aug 17, 2010 at 10:33 PM
I use the Unity specific Google search a lot: http://www.google.com/cse/home?cx=002470491425767499270:iugs1ezlsfq
It returned this link: http://forum.unity3d.com/viewtopic.php?p=237063
Which has one relevant sounding reply in the form of:
"Use a Particles/Additive shader for the water volume, with liquid animated texture.
And project a Particles/Additive shader with animated caustics on the -Y axis."
Answer by cregox · Jan 27, 2011 at 01:13 AM
Here's how I've done my underwater so far:
- Add underwatereffect.js to the camera (adapted from this):
var fog = true; var fogColor = Color (0, 0.4, 0.7, 0.6); var fogDensity = 0.04; var skybox : Material;
function Start () { RenderSettings.fog = fog; RenderSettings.fogColor = fogColor; RenderSettings.fogDensity = fogDensity; RenderSettings.skybox = skybox; }
- Add bubbles.js to underwater objects (made based on this):
var materials : Material[];
private var particlEmitter; private var particlAnimator; private var particlRenderer;
private var speed;
function Start () { particlEmitter = gameObject.AddComponent("EllipsoidParticleEmitter"); particlAnimator = gameObject.AddComponent("ParticleAnimator"); particlRenderer = gameObject.AddComponent("ParticleRenderer");
particlEmitter.minSize = 0.1; particlEmitter.maxSize = 0.2; particlEmitter.minEnergy = 0.5; particlEmitter.maxEnergy = 2; particlEmitter.minEmission = 10; particlEmitter.maxEmission = 20;
particlAnimator.doesAnimateColor = false; particlAnimator.sizeGrow = 0.5; particlAnimator.force.y = 2;
particlRenderer.materials = materials; }
function Update () { speed = rigidbody.velocity.magnitude 3; particlEmitter.minEmission = speed; particlEmitter.maxEmission = particlEmitter.minEmission 2; }
doesn't work exactly it applies the fog and effect to everything ins$$anonymous$$d of just underwater I modified it a little so that it only turns on when you go under water but it stays on forever ins$$anonymous$$d of going off. Any Ideas?
@Tracey it depends a lot on the game implementation, but in general you can set an update function to identify if the player Y position is higher or lower than a set level, and do the switch according.
change it so the fog script is. onEnter ins$$anonymous$$d of start and OnExit to exit the water.
Answer by mukul18khanna · Dec 26, 2017 at 11:38 AM
This might help- https://medium.com/@mukulkhanna/creating-basic-underwater-effects-in-unity-9a9400bde928