I know nothing about C# also, but I think your script roughly translates to this:
var waterLevel : float;
var floatHeight : float:
var buoyancyCentreOffset : Vector3;
var bounceDamp : float;
function FixedUpdate () {
var actionPoint : Vector3 = transform.position + transform.TransformDirection(buoyancyCentreOffset);
var forceFactor : float = 1f - ((actionPoint.y - waterLevel) / floatHeight);
if (forceFactor > 0.0) {
var uplift : Vector3 = - Physics.gravity * (forceFactor - rigidbody.velocity.y * bounceDamp);
rigidbody.AddforceAtPosition(uplift, actionPoint);
}
}
I’m pretty sure this won’t compile without errors as I noticed there are several undeclared variables in there. I’m also not sure if you need to declare the variable types in the FixedUpdate () function. This is a super quick hack and I’ll be interested to see how close to being right I got.
Incidentally, I believe Andeee posted a buoyancy script a long while back. Is this that script? I thought he posted one in Javascript?
Or is this the script from the Ocean project? I sort of recognize it now…
Good catch, go ahead and change the “1f” to “1.0”. I’m sure there are other things I may have missed as I really don’t know C# at all but thought this might be a good time to learn a bit.