Water Questions

Trying to work through water.

Can I either:
a) change the shape of the Nighttime Water prefab to something besides the weird oval?
b) Get it to look like it does in the Prefab on my own geometry? When I place the Nightime Water material on my plane, the water looks thin and stretched - almost like the UV’s were projecting the wrong way (although I’ve checked the UVs and they are correct).

Thanks.

You can use the nighttime water material on any object. Is your plane rotated the right way around? The material really only works on horizontal surfaces; try the built-in plane (Gameobject → create other → plane) which works fine. The prefab just has the water wave scroll script attached, which is used for an effect on old cards that can’t render water properly. So you can add that script to any object too.

–Eric

Water uses a couple of scripts and materials to actually work. So the easiest way to change the geometry is dragging the example prefab and changing the Mesh it uses. Full docs are here.

So, is there anything you can do in indie to make the water plane object undulate behave like water?

M

Hmmm… just thinking of somthing very cheap :wink:

Make a lowpoly-copy of the boat, flip it on the horizontal axis, and let the mesh deform a bit back and forth by script… place it under the original boat and make the water slightly transparent… maybe that can fake a little reflection? Also use an animated texture with those typical underwater patterns on the “Mirror-object”. Might help to make it more realistic…

By the way… nice atmosphere in your screenshot! Cant wait to fire some torpedoes there!

You can use the mesh scripting interface to do that. There would be some math involved though, but maybe you could get decent results just by applying some sine waves. You could probably even have some interaction with boats on it, but that would start getting a little complicated. Probably best just to fake that part.

–Eric

you can access the vertices in the mesh and move them. you’ll probably need a pretty dense mesh and some tweaking to get it good. unity can move a fair amount of verts tho. see the procedural example for how to.

wadamw

Sorry for hijacking your thread.

AL. Thanks! E P too…

-Crumple mesh is very jerky, I like the mirrored boat idea. I’ve also tried animating it with lots of little bones, but that looks very similar.

Haven’t tried sine curves, that sounds more like it.

  • Excuse my ignorance but what does it mean at the top of a script where it says… the Author is not responsible for any harm or damage? What sort of damage? If I start writing scripts what sort of potential risk am i facing?

Thanks.

M

didn’t see eric posted too. what he said!

lol… that’s just otee releasing scripts with a cya clause. “cover your a**” if it crashes your machine, not my prob!

Aras…thanks much. I swear I had read that same documetation 4 times and for some reason misunderstood that Mesh Filter. Thanks for pointing me at it again. Worked great.

The sinus curve modifier worked the best… I tried mesh morphing 3 ocean meshes together but couldn’t get it to cycle.

Not as choppy as I would have liked but it’s a nice rolling sea. how would I modify the script so there is another curve perpendicular to the existing one?

Thanks!

M

Yeah, unfortunately the mesh morpher doesn’t really work.

Well, if you modify the line in the SinusCurveModifier script so that it’s

vertex.y += Mathf.Sin(Time.time * speed + baseHeight[i].y + baseHeight[i].z) * scale;

That gives you a wave only on the Z axis. If you change z to x, then you get a wave only on the X axis. Stands to reason that you can combine the two, and cut the scale in half so it stays consistent:

vertex.y += Mathf.Sin(Time.time * speed + baseHeight[i].y + baseHeight[i].z) * (scale/2)
			 + Mathf.Sin(Time.time * speed + baseHeight[i].y + baseHeight[i].x) * (scale/2);

–Eric

E

Good going thanks for that will get onto it and yes, that sounds logical but I am a total newb to scripting.

M :slight_smile:

just wanted to say that’s looking pretty good - the waves do alot for the atmosphere ; )

Cool, that worked.

hey all, excellent resources on this page. I also found a couple of interesting things Water Rendering and Simulation and on this opensource opengl project. I’m really interested in the realtime Tessendorf simulation that they discuss and would really like to introduce it into a simple project I’m doing… I guess I wanted to know from you how much I could get out of Unity in terms of real time simulating a single ocean environment vs. coding in pure opengl which i’m a also a bit familiar with. Any tips appreciated.[/url]

How did you go with your projects meshpig and wadamw?Cheers

Still at it… but that’s funny because before danger from the deep was ported to mac, you could download the source files which included all the scripts for the water. I mean i have had them for a while. Now you can just downlaod the game and play it incomplete.

I was just going to post the obvious question, since I think it’s in C sharp, how much of that is usable in unity not being familiar at all with coding and on indie until?

Cheers!

M

Add this to the end of the SinusCurveModifier to make objects
float on top of waves

GetComponent(MeshCollider).sharedMesh = mesh;
@script AddComponentMenu ("Mesh/Deform/SinusCurveModifier")

var scale = 10.0;
var speed = 1.0;
private var baseHeight : Vector3[];

function Update () {
	var mesh : Mesh = GetComponent(MeshFilter).mesh;
	
	if (baseHeight == null)
		baseHeight = mesh.vertices;
	
	var vertices = new Vector3[baseHeight.Length];
	for (var i=0;i<vertices.Length;i++)
	{
		var vertex = baseHeight[i];
		vertex.y += Mathf.Sin(Time.time * speed+ baseHeight[i].x + baseHeight[i].y + baseHeight[i].z) * scale;
		vertices[i] = vertex;
	}
	mesh.vertices = vertices;
	mesh.RecalculateNormals();

GetComponent(MeshCollider).sharedMesh = mesh; 
}

[/code]

This topic interests me also. How are you making the objects “float”? I added a collider and rigidbody to a sphere, but it doesn’t seem to be interacting with the plane surface properly. How should it be working?

I also thought that the boat’s bobbing could be made a bit more realistic looking by using an collider attached to an empty GO, then attach your boat to that with a spring.

Other ideas?

http://unity3d.com/examples/VehiclesExample.zip

Theres some cool boat action goin on there
AC