How do I simulate a tsunami wave?

I’d like to hear the community’s ideas on how to simulate a Tsunami and the possible damage it could cause to an environment within Unity.

For instance if I have a small costal town mesh, I’d like to simulate a constant wave coming across the ocean and then causing multiple collisions on the buildings/objects in the town.

I guess putting colliders/rigidbodies on the town buildings and implementing the neccessary damage system is fair enough, but what I’d like to hear about is how would one go about implementing the actual wave physics that causes the damage and collides with the buildings…

I was thinking of having a bunch of cylinder rigidbodys with mass that ‘roll’ along with the wave and could use them as the damaging forces. Has anyone got any great ideas on how to do this sort of thing?

Thanks

I thought i’d just include my thoughts on this, as Cristian H Pedersen says “This sounds advanced” and you could use a lot of input.

Just my quick thoughts over a coffee, i had thought about the mass use of rigid bodys.

The Town:
Possibility on using rigid bodys to construct the house and freeze all the positions and rotations. But when the wave hits, unfreeze all the positions and rigid bodys so it can be affected. I am fairly sure this shouldnt cause any ‘lag’ to the system (aslong as its PC).

The Wave:
This is a little complicated as anyone would guess already. You could for example have a grid of ‘plane’ rigid body’s that lay flat and when you want to simulate the ‘wave’ you can as you said have cylinder rigid body’s that can only act with the plane rigid body’s. So if you place the ‘roll’ as we will call it under the planes and have them adding a force in a certain direction the planes will obviously act upon it. Or you could have it where the roll will do the same as previously mentioned but the planes will act upon the position of the rolls. Meaning that if the rolls started at say for example position 0,0,0 and they were rolling on a positive X axis then the planes at say 10,0,0 would have a rotation value of for random example 40,0,0 (if you get my meaning). So this would be colliding with a collider that is surrounding the rolls.

The Impact:
So after all the waves start acting up and collide with the ‘town’ the walls of the separate houses could collide with the collider of the rolls and unfreeze all the positions and rotations so that they can break and float away.

The ‘Floating’:
My main thought was is how are you going to implement the floating of some of the wreckage (if you are going to have anything floating). I’m not sure if you could manipulate the rigid body to be extremely ‘light’ so that when colliding with something it stay’s ‘afloat’?

Hopefully that gives you some insight, sadly i cannot really do any of this or test anything or provide any code as i have my own projects to get on with but i am very interested into how you have ‘hopefully’ achieved this :slight_smile:

More explanations to how i would do this:

So, to expand on my previous answer, once again over coffee…

The Town: As previously explained, i would create every wall, ceiling and whatever out of planes(or objects you would prefer). These objects would have a rigidbody to them. These rigidbodys would have their positions and rotations frozen so they will stay in place. You can place these houses on a flat plane or a terrain setting. Either way like any house seen today, you would place it on a flat terrain, or your mental and live on a hill :stuck_out_tongue:

The Wave: So, i had more of a thought about this and i think i will take back what i said before and change most of it. If some of it sounds similar to what i said before than i am sorry but it is quater to nine in the morning, my face is wrecked :P. So anyway, what i would do is that i would create a ‘grid of planes’ to represent the sea. Now this ‘grid’, dont take it literally as a GRID, what i am thinking is that i can have it placed in a random way that its not in rows and columns( i will attempt to draw a picture and upload it if need be). Reasons why i say make it random and not rows and columns is because the sea + wave would look awful. And we dont want that. Picture a wave now in your head that is made of polygons. You instantly do not think of it to be box like <---- thats what it would like if you made it rows and columns. Make it random so the wave looks realistic.

Now To make the sea look like its moving about, instead of cylinders i thought about using spheres…LOTS OF THEM. I’d place them under the planes and have them randomly moving about. I’d lock their Y axis also, why you ask? Because instead of them random moving up and down at radical places, i myself would place them on the Y axis to where i want them to be. Now when i say moving about to random places, what i mean is that i’d write a script to say, here is your start point, move to the finish point, are you at the finish point? Yes? Move to the new finish point. Now a lot of you are instantly going to think “But wait, how is that going to move the planes about?”. I am pretty sure most of us here at Unity Answers, or more ALL OF US, are scripters/programmers, so maybe there is a way to place a child object on each of the planes to allow it to have a rotation value to create movement on the planes. I suspect i am confusing most of you now, so i will explain.

Picture this, you have 4 Planes, each side by side looking like a box (so if you think coord’s, (1,1),(1,2),(2,1) and (2,2)). Place a sphere under the planes in the middle of the 4 planes(RIGHT IN THE CENTRE). Now i would lock the rigidbody on the sphere on the Y axis but allow it to move like i previously mentioned. Now, on each plane i’d have a child object that is a sphere. This sphere would be placed in the middle of the each plane, right bang in the centre so that the top half of the sphere is above the plane and the bottom half is under the plane. Why you ask? because THAT is going to give the plane the rotation values for it to move in a wave like manner. So when the sphere moves say towards the top left of the plane (1,1) the bottom right of that plane will be down and the top left will be up. Now i can see already that there is a problem there that the other 3 plane wouldnt be affected…well, to fix that, affect them! If the bottom right is going to be down, allow the other 3 planes to match it. Hopefully you see where iam getting at with that, if not, i can explain further with images.

Ok, i think i am getting lost into my own words now, that i am very very tempted to make this (dam you OP). So if you do what i said previously above this paragraph as many times as you want, you would create a sea like looking thing…not good english at all there. Now moving swiftly on to the WAVE!

The Wave:
So whenever you want the wave to crash into the town, simply activate a boolean to start it up. Now this depends on how you want your wave to look because there is 2 ways, if you think of a traditional tsunami, the water looks as if it is raising. Or you could simply create a ‘wave’. Naff it i will just explain both.

Wave A:
Now to simulate a wave in general is going to be pretty difficult, i hope you understand that(or thats really to my thoughts). With this first example, the water raising, i’d simply do what it says, raise the water! Now when it is gaining height, whenever you can, add another plane, thats when you have space. OR. You can have pre build planes in place but will only be able to do anything when they are above ground.

Wave B:
This would mainly be done with an animation but within that animation (inside it) you would have multiple spheres at different sizes and they would be making the impacts and creating the wave itself.

I can explain more on that, but i think this post is long enough as it is! :stuck_out_tongue:

The Impact:
So, the overall impact, since everything (everything being the water and the initial wave) will have a collider on it, lets put tags on them. Tags in my opinion are key in this idea of mine. When the water/wave/whatever hits a house, allow the house to realise that THIS SPECIFIC TAG has collided with it and it needs to unfreeze all of its positions and rotations to be able to fly about. Now as we know rigidbodys are lovely things to play with, and we know that we can create bouncy objects or rock solid immovable objects. Lets go wild and make the houses light and moveable, so when the initial impact happens, its crumbles apart.

CONCLUSION:
I think i have written far too much here :stuck_out_tongue: So if anyone is confused or has any questions, please feel free to ask. Sadly i cannot make what i am explaining, i wish i could but with my projects needing attention i cannot afford any time to try this out. I will how ever leaveyou my personal e-mail if you want to still communicate after this question/answer. I would also personally like to know how you have achieved this Meltdown as this has been exciting for myself to try and figure things out. Hopefully i have helped and you succeed with this :slight_smile:

I would play around with having a mass of sphere rigidbodies which either use constant force, or simply tilt the whole game world and use gravity. They will flow around buildings like water would. Increment a “force applied” variable on buildings they hit, which shrinks periodically so a building getting hit will break if enough “water” hits it, but not from a mild flow.

I think the wave would be a good thing to animate, where layers of foam move at the very front of the wave (this could also be emitters). The wave itself could be just a plane that twists and bends.
I would definitely look into Rigidbody.AddExplosionForce and let hit alter each rigidbody’s gravity boolean from true to false during the impact.

A few things I want to add:
Think about a wave’s movement. It goes in—and then out again. So you’d need to simulate the houses moving back out to sea again. I think applying some sort of general rigidbody.AddForce would be the way to go with this.
Also, you’ll want destruction! Add a destruction script to the houses, so they get smashed to pieces by the wave! There’s a good one on the forum.

I’ve had a new idea! I wanted to post it as a new answer, because it’s completely different. Why not just use a particle effect? It seems a perfect opportunity. Try modifying the waterfall one to go for it, perhaps. I’ll give that a try (been messing around with planes and that looks good, but could do with some tweaking. Anyway, I’ll post the results tommorrow perhaps?