# 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

yeah my boats a bit jittery to, but thatâ€™s just the engine turning over,â€¦
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.

2 Likes

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

2 Likes