How to rotate boat with waves

I’ve been attempting to make a boat float on water recently, and I’ve come to the point where I can get the height of the water at a certain point, position a part there using body position (or CFrame), but I can’t rotate a part or model to rotate with the waves. I currently have a body position that sets the position of the boat to the water level at the centre of the model. I also have a body gyro that is meant to rotate it, although it seems like it’s either behind, or sampling the wrong point.
This is the code I have to set the rotation.

local xVector = (primaryPart:FindFirstChild('Back').Position - primaryPart:FindFirstChild('Front').Position).Unit
local zVector = (primaryPart:FindFirstChild('Left').Position - primaryPart:FindFirstChild('Right').Position).Unit
local yVector = (xVector:Cross(zVector))
primaryPart.BodyGyro.CFrame = CFrame.fromMatrix(Vector3.new(), xVector, yVector, zVector)

I used this post: Custom Water + Ships - #25 by Soliform to help with the maths, although I can’t figure out what’s wrong with it, even after flipping around Front and Back and changing front and back from X to Z.
The Front, Back, Left and Right parts all have their heights constantly updated to move with the water.
The only thing I’ve changed from the default bodygyro values are MaxTorque, which I had set to 400000, 400000, 400000, but changed it to 400000, 0, 400000 because the model was spinning around super weirdly. Edit: and it apparently still spins as showcased in the video below.

Video of what the boat looks like right now
robloxapp-20230902-1700332.wmv (3.8 MB)

Thanks to anyone who reads and spends the time to help, this is basically a dream project of mine.

2 Likes

Although I would suggest making your ship massless entirely, I could see why you would still want heavy physics on it. Are you trying to make it move to the side?

3 Likes

as i said in an earlier post of yours, and seemingly a similar issue in this post clip and said by @oSudden, i think a main problem here is the physics constraints actually trying to move this massive boat model. here is the link to the fixes i gave: BodyPosition doesn't apply a force instantly, and has a lot of elasticity - #8 by TheEpicPlasmeticGuy

3 Likes

^

This should do the trick, these older forces really only work well on smaller models.

2 Likes

When the body position and gyro are created I fire the server giving ownership to the model, along with unanchoring it and making it massless. I’m just trying to get it to rock with the waves, as seen in these posts

1 Like

Didn’t know that they don’t work too well on larger models, does that still apply even if the parts have massless set to true? Either way, thanks for the info

1 Like

If you want to use massless set to true, the solution (that worked for me when I was making a smaller boat system) was to weld and unanchor all the parts and weld them to a main part the size of the base of the boat, then control physics like that.

2 Likes


That’s how I have it set out currently, with the part Points (the one in the very centre of the ship) being the primary part of both “Pirate Ship” and the model holding everything.
Bit confused on your solution and also not sure how everything is welded on my model, would I increase the size of my centre part to stretch across the entire boat?

You would want your center part being as long and wide as the boat and a few studs in height.
You would need to weld all your others parts to it and unanchor them, to use this method however you will have to change your boat’s wave math to only move that 1 part.

1 Like