current_vertices[current_index].y+=(current_buffer[i]*1.0f/splash_force)*wave_height;//This is what raises the current "tile"'s Y value by the splash force times the maximum height of the wave
}
mesh.vertices=current_vertices;
GetComponent<MeshFilter>().mesh=mesh;
// swap buffers
mesh.vertices=current_vertices;//Updates the mesh! :)
GetComponent<MeshFilter>().mesh=mesh;//Updates it to unity
}
voidsplash()
{
if(Input.GetKeyDown(KeyCode.Space))
if(Input.GetKeyDown(KeyCode.Space))//Will change for microphone output
/* Ray cast function to set the splash position */
RaycastHithit;//Will store all the info on the object the ray will collide
Vector3down=PlayerSettings.instance.player.transform.TransformDirection(Vector3.down);//Create a raycast from the player's position downwards
if(Physics.Raycast(PlayerSettings.instance.player.transform.position,down,outhit))// Draws a ray dowards from the player and stores the impact location
floatxCoord=(bounds.max.x-bounds.min.x)-((bounds.max.x-bounds.min.x)*hit.textureCoord.x);//Sets the X coordinates for the splash
floatzCoord=(bounds.max.z-bounds.min.z)-((bounds.max.z-bounds.min.z)*hit.textureCoord.y);//Sets the Y coordinates for the splash
floatcolumn=(xCoord/* / xStep*/);
floatrow=(zCoord/* / zStep*/);
splashAtPoint((int)column,(int)row);//Generates the splash!
}
}
}
//THE CODE THAT MAKES THE WAVE MOVE AND FADE OUT
//From Ben Britten's code
voidripple_effect(int[]source,int[]dest)
{
intx=0;
...
...
@@ -150,13 +155,9 @@ public class RippleEffect : MonoBehaviour
for(x=1;x<cols;x++)
{
position=(y*(cols+1))+x;
dest[position]=(((source[position-1]+
source[position+1]+
source[position-(cols+1)]+
source[position+(cols+1)])>>1)-dest[position]);
dest[position]=(int)(dest[position]*dampner);
dest[position]=(((source[position-1]+source[position+1]+source[position-(cols+1)]+source[position+(cols+1)])>>1)-dest[position]);//Makes the wave move forward
dest[position]=(int)(dest[position]*dampner);//Makes the wave fade out