by Guest » Sat Jan 12, 2019 7:53 pm
(haha double posting)
Thinking about it some more, maybe it'd work out if the current sinking code is kept on most of the time, but a +BUOYANT flag is added that enables use of new buoyancy code, which would apply Z acceleration when in water, scaled by how far into the water it is, or by water level if that would be more consistent with how the rest of the physics works. The property would be in units/tic^2. Gravity would be factored into this, except for +NOGRAVITY +BUOYANT actors. Actors colliding with each other because of buoyancy would handle the same as if they collided any other way.
For example, an actor with a Buoyancy of 1.5 would, when completely submerged in water, accelerate upward at a rate of (1.5 unit/tic^2 - [gravity] units/tic^2) = usually 0.5 units/tic^2. When only half-submerged, only half its buoyancy would apply (the net Z acceleration would be -0.25 units/tic^2). If going by waterlevel, then waterlevel 1 uses 33% of the buoyancy property, and waterlevel 2 uses 67% of the buoyancy property. An actor with a buoyancy of 0 would sink in water exactly like it would sink in air. The default buoyancy would be 1.
+DONTSINK would still be useful to completely disable all of that if you want - for example (and this is the example that prompted it in the first place), if you want to implement a different game's swimming physics.
(haha double posting)
Thinking about it some more, maybe it'd work out if the current sinking code is kept on most of the time, but a +BUOYANT flag is added that enables use of new buoyancy code, which would apply Z acceleration when in water, scaled by how far into the water it is, or by water level if that would be more consistent with how the rest of the physics works. The property would be in units/tic^2. Gravity would be factored into this, except for +NOGRAVITY +BUOYANT actors. Actors colliding with each other because of buoyancy would handle the same as if they collided any other way.
For example, an actor with a Buoyancy of 1.5 would, when completely submerged in water, accelerate upward at a rate of (1.5 unit/tic^2 - [gravity] units/tic^2) = usually 0.5 units/tic^2. When only half-submerged, only half its buoyancy would apply (the net Z acceleration would be -0.25 units/tic^2). If going by waterlevel, then waterlevel 1 uses 33% of the buoyancy property, and waterlevel 2 uses 67% of the buoyancy property. An actor with a buoyancy of 0 would sink in water exactly like it would sink in air. The default buoyancy would be 1.
+DONTSINK would still be useful to completely disable all of that if you want - for example (and this is the example that prompted it in the first place), if you want to implement a different game's swimming physics.