interactive water possible?

Enoch

  • Posts: 28
Hello again! Although I am still rather new, I feel a little more confident in my (very basic) understanding of stencyl. However I had some questions about making water. I'm pretty inexperienced when it comes to programing (well, I really don't know much of anything) but I am very interested in creating an innovative and engaging environment inside my game. So what I am trying to find out is what is the best way to make interactive moving water inside Stencyl.

I found two videos I thought where intreasting and may be possible, however I would like to know what the best one is (for stencyl) and how to go about making them a reality within the game.

Here are the links:

"Test simulation of a two dimensional cross section of a fluid surface."
http://www.youtube.com/watch?v=Iqg0XDpV-Jg&feature=related

Not sure what this is... SPH?
http://www.youtube.com/watch?v=0bL80G1HX9w

I believe I could replicate the second video by using actors made of large circle with small collision box. Here is a diagram of what a mean.



Of course the "water molecules" would have to repel each other so they done get to close while still maintaining a bouncy surface. Well that's the idea anyways.

The first one is much more realistic however I have no idea how to go about doing that. Well I don't know how to do either really. Does one have any ideas how to go about this? As I said before I have no programming skills and am trying to learn how to use the design mode. Is this concept even possible?
"...he manifests himself as an absence; as though he weren't there at all."

Enoch

  • Posts: 28
Ah, a few views but no posts. Any ideas or should I just start experimenting? (bump)
"...he manifests himself as an absence; as though he weren't there at all."

Greg

  • *
  • Posts: 1260
I'm not going to say it's impossible, but I'm having a hard time thinking of a good way to pull something off that would also look realistic.  I know that Box2d does have a concept of buoyancy, I just don't think it's in the version that we're using.   

Enoch

  • Posts: 28
Sorry if I don't fully understand but Stencyl uses Box2d?

And rather then programming buoyancy is there anything I can do that may be similar? Just giving actors properties that would allow them to mimic water movement based on how the collided with other objects and how they interact with each other.

My original idea of making them slightly repel was to try to simulate buoyancy but without anything to complex that would slow the game down.


« Last Edit: July 01, 2011, 05:52:16 pm by Enoch »
"...he manifests himself as an absence; as though he weren't there at all."

dineyin

  • Posts: 110
You can definitely do that, but I believe the overhead of having physics for all those "Particles" will quickly slow down your game.

The first video you posted seems a lot more possible in Stencyl since it's just essentially a bunch of joints hooked together to form a water surface.

I think that it really depends on how you want the water to behave in your game. If the water is supposed to flow and move around then you probably have to go with the second system. If you just want to have static areas of water your character can jump into then you can probably get away with the first system.

In any case, this is going to be a rather complex problem to solve, and you would probably do better learning some of the more basic features in Stencyl and programming in general before you try this (though sometimes jumping into something over your head can be a great learning experience)

Enoch

  • Posts: 28
Ah that is a shame but you may be right. It would probably take a lot of "water molecules" to effectively mimic water. And the first one looks extremely complex, I saw some one do it on "Game Maker" however a while ago but I have no idea how he was able to do it.

Still, even after a get more skilled in the design mode, I'm not sure where I would even start from something like this. Originally I wanted to make water that flowed and I had a good concept of where to start however it seems likely to cause problems by requiring to many actors. but the first video that uses "a two dimensional cross section of a fluid surface" seems to complex to make in the design mode... I don't need an exact answer but a starting place would be nice.

Otherwise I'll wait until I'm more experienced.
"...he manifests himself as an absence; as though he weren't there at all."

dineyin

  • Posts: 110
So this is how I would do it (see attached picture) essentially you'd have a bunch of objects that make up the water surface (red boxes) and connect them with joints. That way whenever something hit one of the objects they would bounce around kind of like water. The more you have the more fluid it should look, but even with just a few it should look pretty cool I think

Once you actually have that working you can draw the actual water by using the "Draw Polygon" block by connecting all the blocks.

Enoch

  • Posts: 28
This sounds like a very good solution. I have never used joints or the "draw polygon block" so it may take a while but it is a start. Thank you very much!
"...he manifests himself as an absence; as though he weren't there at all."

Greg

  • *
  • Posts: 1260
I played around with implementing dineyin's solution and it turned out pretty interesting.  I ended up making the water "nodes" sensors.  When they detect a collision, they apply a downward force -- and since they're attached by joints - it gives it a nice springy effect. 

http://www.stencyl.com/game/play/4804

dineyin

  • Posts: 110
Pretty cool, that actually looks better than I thought it would look :) . I can see that it does have the problem of sagging in the middle, but I think that it definitely has a kind of liquid feel to it

Epic428

  • Posts: 1118
I imagine you could tighten up the joints a bit to reduce the sagging effect.

Anyway, great job on this Greg! One thing I'm curious about is how you managed to get the light blue to draw dynamically like that.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Greg

  • *
  • Posts: 1260
Yeah the sagging is a bit much, and it leads to the bounciness.  I tried tightening up the joints to no avail.  Might be possible to connect every other node by joints to see if that helps, but I'm not sure what it will do to the effect.

As for the drawing - I'm basically using the "draw filled curve" block and then adding a point at each water node (currently hardcoding the rest to make it have a rectangular bottom).  This is what the scene looks like untouched.


Epic428

  • Posts: 1118
Ahh that is very interesting. I've used the draw curve function before, but I hadn't used like this. Pretty cool.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

Joe

  • *
  • Posts: 2480
Bravo, Greg! That is pretty convincing. :)

dineyin

  • Posts: 110
Maybe try reducing the mass of each node? or reducing gravity?