Hello
I have some questions about creating water-waves. I know how I can make normal waves to let my water look like it’s moving in a direction. This is my Script: (It also has some Functions to let my Water looking a bit random)
#pragma strict
var Speed : float = 0.001;
private var offset : float;
var offsetSpeed : float = 0.1;
// How smooth should it be
var Smooth: float = 20;
// Speed of the Wave
var SpeedX : float = 20;
var SpeedY : float = 20;
// This makes the water more random
var RandomFactor : float = 2;
var Randomizer : float = 1;
private var yVelocity = 0.0;
// The Mesh
private var mesh : Mesh;
// The Base Vertices of the Mesh
private var BaseHeight : Vector3[];
private var vertices: Vector3[];
function Update()
{
// change offset
offset += Speed;
//This Variable is to make the waves more random
Randomizer = Mathf.SmoothDamp(Randomizer,Random.value*RandomFactor,yVelocity,10/RandomFactor);
// Move the Mesh Up and Down
for (var i = 0; i < vertices.Length; i++)
{
//vertices<em>.y = Mathf.Sin((offset+vertices<em>.x+vertices_.z)*Speed+offset*Bonus)/Smooth;_</em></em>
vertices.y = Mathf.Sin( (offset+vertices.xRandomizer) SpeedX + (offset+vertices_.zRandomizer) SpeedY )/ SmoothRandomizer;
vertices.y += BaseHeight.y;
}*_
* // Attach the new vertices to the mesh*
* mesh.vertices = vertices;*
* mesh.RecalculateBounds();*
}
But how can I make the water react to a contact, I tried some things with my normal function but can’t get a good effect.
I’m happy about every idea you have for this.