Where did you put your buoyancy points?

I had one at the front, back and either side. I tried to make them even but my boat jitters

I believe I had 2 at the back corners, 2 on each side mid way down and a single at the front.

I thought my boat jittered from my restless leg. I didn’t think it was it the game :wink:

yeah my boats a bit jittery to, but that’s just the engine turning over,… :stuck_out_tongue:
One front, one back, one either side. Tried to find the balance on gravity, force factor, and height of each of them. Got good enough, rather than perfect.

My guess is you are all using a single if statement to trigger the force when gravity takes it below a certain level.
You may need to be more clever in that area if you dont like the jitters/engine shudder/wave movement.

May be playing with gravity or less force when near the surface, increasing with depth or thinking about it just moving with the wave when stationary…

1 Like

In my prototype I used 4 points - one on each corner.

If you’re movement is jittery then it’s most likely related to how you’re applying your forces in the Buoyancy script.

If you want a big old spoiler then let me know and I can share the 2-lines of code that I added to get mine working nice and smoothly.

1 Like

I’m just using
myRigidbody.AddForceAtPosition(Vector3.up * fluidForce, transform.position, ForceMode.Acceleration);
in the buoyancy script (the water level check was already there)

I thought my cubes were fine so I thought it was the position of the points because its an irregular shape and the cubes are nice and even. Now I’m not so sure, I can’t tell if they’re jittering too or its because the camera is following the boat. I’m sure they were fine before I changed to acceleration and changed the gravity.
Now my boat is tipping sideways even though there’s no wave and the buoyancy points are the same height each side. I’m just making it worse lol

1 Like

im similar but different on my code @Hazel_Ryan

Code and chat about code, and potential solution idea
		if (transform.position.y > WaterLevel.CurrentWaterLevel) { return; }
		else if(transform.position.y <= WaterLevel.CurrentWaterLevel)
			rb.AddForceAtPosition(new Vector3(0f, fluidForce, 0f), transform.position, ForceMode.Acceleration);

Think my logic was to ensure the fluid force was only happening in the up direction, i assume your version and mine equate to the same thing on that front.
Beyond that i assume it’s like Eddie mentioned above, there needs to be a bit more in there so that the force is at 0 when it’s AT water level,… and increases further away. I kind of “assumed” ForceMode.Acceleration, would have done something like that, but now think maybe i don’t understand it properly.

Perhaps the solution is by just multiplying that fluidForce by the water level - the boats Y position, or something similar. Will mean the fluid force might need increasing, but when X by 0 it’ll be at 0,… and when the boats at -0.1 difference (watch out for the negatives?) it’ll have some but a lower force, then if it was at -1 of the water level,…

Here’s how I did it.

if (transform.position.y > WaterLevel.CurrentWaterLevel) { return; }
rigidbody.AddForceAtPosition(Vector3.up * fluidForce * (WaterLevel.CurrentWaterLevel - transform.position.y), transform.position, ForceMode.Acceleration);

This subtle change should solve your jitter problem and make your objects bob nice and softly in the water.
For reference, I used a fluid force of 15 and gravity around -40.


wooo i was theoretically right :smiley:
Shame it took me so long to engage my brain to think about it :smiley:.
Thanks Gary! :slight_smile:


Privacy & Terms