Sign in to follow this  
haykan648

Unity3d Simple Soil Simulation

Recommended Posts

Hello .

 

I just wanted to know whats the best way to make a simple soil simulation , 2D of course, something like Pocket Tanks that you can move on it .

 

-Is working with mesh and mesh deformation good enough ?

-it's just for a mobile game i don't want to create small cubes or planes that will lead to low performance.

 

Thanks and please help me.

Share this post


Link to post
Share on other sites

You can draw such terrain with a single quad. Just create a texture either by rendering your terrain into it somehow or by filling it texel by texel yourself. Or you can use fragment shader that discards or fills fragments according to fragment's position (x,y) and 1D-heightmap values (index heightmap with fragment x position and compare returned value with fragment y position). In case you'd want to have holes you'd need to modify the shader a little bit.

 

Rendering with a mesh doesnt look promising to me, especially, if you want it to be dynamic ("sandy") as it was in Pocket Tanks.

Share this post


Link to post
Share on other sites

You can draw such terrain with a single quad. Just create a texture either by rendering your terrain into it somehow or by filling it texel by texel yourself.

how will the physics work then ? should i write it by myself?
 

Share this post


Link to post
Share on other sites

It depends very much on how realistic you want it to be and if it is suppose to work like a height map or particle simulation.

 

Working with particles can be very realistic but needs a lot of calculation power. The height map method is very fast but can't deal with things like caves or bridges (like the unity terrain tools). 

 

I worked on a height map based soil simulation before for 3D something like this: 

 

https://www.youtube.com/watch?v=VC1XfG2SY_k

 

It gives every square metre (or every metre in 2D) a height value and velocity to simulate the movement of soil. A bomb or a heavy tank will accelerate the soil and cause the movement of the ground.

 

Edit: Just checked out Pocket Tanks. Wouldn't even call that a simulation tongue.png

Edited by devluz

Share this post


Link to post
Share on other sites

 

You can draw such terrain with a single quad. Just create a texture either by rendering your terrain into it somehow or by filling it texel by texel yourself.

how will the physics work then ? should i write it by myself?
 

 

It depends on what you need. Maybe, approximating terrain with a polyline and using box2d or chipmunk will be sufficient for you. Otherwise, most probably you will have to do it yourself. But first of all you need to decide what you want your game to be.

 

I worked on a height map based soil simulation before for 3D something like this: 

Awesome. It could become a great game.

Share this post


Link to post
Share on other sites

 

You can draw such terrain with a single quad. Just create a texture either by rendering your terrain into it somehow or by filling it texel by texel yourself.

how will the physics work then ? should i write it by myself?
 

 

 

You update the texture every frame. You handle positions of the dirt as a series of dirt-columns across the screen. Every frame you update by breaking columns where an explosion hits them (or crater, etc) and then output that to the texture. To speed it up you could also write just the changing parts of the world to the texture, instead of the whole thing.

 

There is also the requirement that you can code simple abstract concepts, like an array of dirt columns, and be able to generate textures.

 

Whenever I want to do something that I don't know how to do, there is always learning involved. So, be prepared to learn something.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this