Boat "suspension" - Flipping/acting weird with body forces

I have a boat with the following structure:

The orientation is calculated with the following code:

local b = Instance.new("BodyPosition", chassis)
local chassis = workspace.Boat.Chassis
local joints = workspace.Boat.Joints

game:GetService("RunService").Heartbeat:Connect(function()
local frontLeft = joints.FL.Position
local backLeft = joints.BL.Position
local backRight = joints.BR.Position
local backLeft = joints.BL.Position

local front = (frontLeft - backLeft).unit
local right = (backRight - backLeft).unit
local up = right:Cross(front)

local x = (joints.FR.Position.X + joints.BL.Position.X)/2
local y = (joints.FR.Position.Y + joints.BL.Position.Y)/2

local mass = chassis.Mass.WorldPosition

local result = CFrame.new(x, y, 82, right.x, up.x, -front.x, right.y, up.y, -front.y, right.z, up.z, -front.z )
local pitch, yaw, roll = result:toEulerAnglesXYZ()
b.position = Vector3.new(x, y, 82)
b.maxForce = Vector3.new(500000000, 500000000, 500000000)
chassis.Mass.BodyGyro.CFrame = result
end)

As you can see though, it acts weird when a human sits/touches it.

This is how it acts when no one is sitting/touching it (and this is how it should be when someone is touching/sitting on it).

Any ideas?

4 Likes

It’s probably affected by the humanoid weight

It is not just humanoid weight, it is how it reacts with everything
https://gyazo.com/04a351224e63aee52b89550d614e472f

2 Likes

try making the part massless and see what happens. Because I am certain that it has some type of collision with things

Collision for the wood frame has to be on, but everything is set to mass-less and it does not work

Sorry if I’m a bit irritating, but maybe test out if gravity is affecting the boat, so try turning the gravity down in game settings

I don’t want to modify gravity in order for this to work, something is up with the physics configuration of my boat

ok then, I’m stumped. I can’t seem to figure it out either, sorry for wasting your time

Haha you didn’t waste my time, thanks for trying to help me though! I do appreciate it :slight_smile:

1 Like

I’m not sure of the exact physical model of your boat (as you seem to have multiple forces, not sure if the “Joints” have force in them?), but it seems like your BodyGyro force in the main chassis is attempting to correct for the tilt due to you standing on it. However, it over corrects and start oscillating. Try to tune the P and D values of the BodyGyro as well as limit MaxTorque to something reasonable.

Do you mind uploading the .rbxl file so the members can look into it?

1 Like

Sure, I’ll attach the file once I’m home later tonight!

1 Like

Thank You! I really appreciate it.

1 Like

BoatPhysics.rbxm (11.5 KB)
I’ve attached a copy of it. Put it in some terrain water and experiment around, you’ll see how it seems to glitch.

Unfortunately, the file you attached doesn’t open. Can you attach a .rbxl file or attach the link to the game and make it uncopylocked.

1 Like

It is an RBXM (model) file, you have to drag it into studio.

1 Like

To be more specific, open a baseplate, then drag the rbxm file from your desktop or file explorer into the world.

Thank you! I’ll try it out. 30 characters

1 Like

For some reason when I hit run, it just decides to go underwater. I have tried lifting it up above water using the move tool, but then it flies back down underwater.

Inside if OrientationCalculator it sets the position of the BodyPosition force:
b.position = Vector3.new(x, 2.5, 82)
I had it like that to test the “wave handling” mechanics

1 Like