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 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 Code (csharp): 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: Code (csharp): 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
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 Code (csharp): GetComponent(MeshCollider).sharedMesh = mesh; Code (csharp): @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?
Targos, glad you changed your avatar image. I thought previously maybe you were being tied up and held to ransom? -I haven't opened Unity these past few weeks because just geting right into spline patching. I mean for better boat hulls, but the bike first... Just reworking this mess: M
Targos ... and serious boat action as you say! http://unity3d.com/examples/VehiclesExample.zip Where's that from? M
An approximate way to model a floating object is to think of it as having a "centre of buoyancy" which generally doesn't coincide with the centre of mass. If you think about a car, the centre of mass is located near the heavy engine - this part of the car would sink first if it were on water. The floating force is applied through the centre of buoyancy. This is quite easy to do using Rigidbody.AddForceAtPosition. The floating force behaves like a compressing spring vertically placed between the centre of buoyancy and the surface of the water. You can probably use little or no damping on the floating "spring" and get a nice bobbing effect for free. If the water has waves which are large compared to the size of the boat, then the spring calculation involves detecting where the surface of the water is. If the boat is quite long, then it should pitch with the waves. You could have, say, four buoyancy points in this case, spread out over the length of the boat, each applying a quarter of the total force via its own spring. A wide boat would also need springs across its width, of course.
Lush bike Meshpig. Those are scripts Joachim wrote, but the models aren't ideal polycount so the package isnt heavily advertised. Its a fantastic package though, and Im sure Im not alone in my appreciation of this. Pete did a bike demo a whileback, and my classmate did a pushbike type bike race last year, Im pretty sure both were based on using raycast colliders... Can we see your bike in a "Its parked and Im in first person" scenario? Pls? AC
Targos Thanks!... sorry for taking up so much space. In it's entirey it comes in at around 130 000 polys and growing. I ran into all sorts of problems fitting it all together which is why I am rebuilding it now. Will do when I have something. Hey, that's the best darn wake, awesome Joachim... How do you mean "not ideal poly count"? M
Heya Meshpig, The sweet spot for polygon count per individual object == 1500-4000 polies each time. Once yo get above this bottlenecks in performance start to occur. On my beasty g4 I can still get good framerates in moderately sized scenes If I adhere to this, and dont bloat the textures too big, and cut down my use of trilinear filtering. Unity can currently do meshes up to 65000 polygons, but I definately see the perfomance hit here. So if your bike was the only thing in a scene at say 60000 polygons, it would probably run ok. But if you used it in a racing game, you'd want to either break it into smaller bits, or cull geometry. Always aim for the sweet spot if you can. AC
Targos Cool, thanks for that. The bike grew out of low poly stuff for animation. Not intended for games as it is... but yes it has keys in the ignition and dials with moving needles so it will look OK from the rider's perspective. I guess for a game you'd just set up the front end. My thrill for the week though is discovering spline patching. I knocked up the rough outline for the bodywork in 3 hours today... it's not great but I can now model it with those views in mind. Cheers. M