(05-23-2011, 05:54 PM)xiphirx Wrote: Yea, I'm able to rotate it too, but in game it acts as if its a giant cube instead of like how its supposed to...
I just tried making "steps" of water areas to emulate a slope. However, this doesn't seem to work.
I think the solution to this is going to require scripting buoyancy to a degree. Obviously we can't clip the shape by the area and calculate the submerged volume using current methods provided by the engine, so we are going to have to assume all objects are spherical - which unless you require perfect physics here is a fair sacrifice.
The idea is thus:
- Create a water plane as normal. This will be the surface.
- Create a thin script area running parrallel to the water plane. Call it liquid_1. This area should have a collide callback triggering on something like "object_*" with all floating objects prefixed with "object_". Have this call a function in your hps file on both entrance and exit.
- Duplicate the script area multiple times so we have various "slices" beneath the water area.
- Write some code to flag how many "tiles" each object is and store this information.
- For each object that is flagged apply a force away from the water based on how many tiles the object touches.
I am working on slapping some code together now
Edit Done!
http://www.mediafire.com/?62ywej36g5w887w
Notes:
The values of the vector * volume displaced are VERY approximate. There is no reason why you shouldn't properly work out these values using some trig, and multiply them against volume. You could also produce a lookup table for objects and their volumes (remember to divide by the maximum no. depth objects they can flag), for much more precise forces when dealing with different sized objects. I am also not going to say right now this is bug free, it was put together in just under an hour (including writing this post), but it seems to behave fairly realistically considering. Finally, this WILL require some tweaking to get to work with saves, thanks to the use of the List class which wont be saved.
Edit 2: You can also apply the effects of current by changing the values of the vector*volume.