Custom buoyancy always ends up being solved with bodyforces, but I’ve never seen a solution to doing it with vectorforce.
The potential of vectorforce for buoyancy calculations is appealing, since you can move the point where the force is applied.
But I’m wondering how to properly take advantage of this feature.
From most to least important (in my opinion), the features of a buoyancy script are:
- Buoyancy
- Translational drag
- Rotational drag
- Flattening on a water surface
However, these features aren’t strictly separate from each other.
If your implementation of buoyancy moves where the force is applied to the centre of mass of the underwater section of the part, then you get flattening.
And if your rotational drag is the result of calculating vector forces for 2 or more points on the part, that’ll also cover your translational drag.
Problem is… I don’t know how to calculate these things! “the centre of mass of the underwater section of the part” is much easier said than done, I don’t even know how to approximate that.
And as for “calculating vector forces for 2 or more points on the part”, firstly you need a way to find out how fast a point on a part is moving when accounting for the part’s rotational velocity, and secondly how do you pick what points on the part to apply the forces to while keeping the number to a minimum?
Oh, by the way, a warning if you want to dabble in vectorforce-based buoyancy scripts: These scripts don’t play nice if a part’s network owner isn’t the one running the buoyancy script, it can cause pretty volatile behaviour.
This means you either have to lock network ownership to the server, or allow the client to do the buoyancy calculations itself and start doing them when it sees that it has network ownership of a part (I’m thinking that the most efficient way to listen for changes in network ownership would be an attribute.changed event caused by the server)