How to make a boat "sink"?

Hi! I am working on a sinking simulation for a big boat, however, I can’t find a way to accurately move the model down. So far, the only solution I have is using a while wait repeat, moving it down slowly, with Model:MoveTo, however, I am unable to do that, as you can’t get a model’s previous position, as far as I know. Would anyone happen to have any ideas?

My (tried) solution:

while wait(0.1) do
		
		boat:MoveTo(boat.Vector3+Vector3.new(0,-1,0)) -- doesn't work, as you can't get a model vector3, as far as im aware.
		
	end
5 Likes

If you want to continue with your linear movement of moving a boat, then :

  1. You need to set the PrimaryPart of the boat, which can be set in the model’s properties. (you basically select a main part inside of the boat).
  2. You move the boat either with MoveTo(position) or SetPrimaryPartCFrame(cFrame). I recommend using SetPrimaryPartCFrame in this situation since the boat will collide with the water with MoveTo()
  3. With SetPrimaryPartCFrame, we do the following code.
boat:SetPrimaryPartCFrame( boat.CFrame + CFrame.new(0, -1, 0) )

You can add this to your while wait(0.1) do loop afterwards.

CFrame is not a valid member of model. Yet, I made sure it’s connected to a part in the model.

Maybe you can set whole body part heavier and heavier and stop when it’s 1, in order to make it sink and not very fast.(If you are using terrain)

Problem here is that a Model does not have a CFrame, but you can get the PrimaryParts CFrame and use that to calculate the new position.
Taking the code from @Cadentopia and using the property from above would make the code look like this:

boat:SetPrimaryPartCFrame( boat.PrimaryPart.CFrame + CFrame.new(0, -1, 0) )

I’ve done that, and a new error pops up; Vector3 Expected, Got CFrame - Argument #2

I believe you cannot use an addition symbol and that it need multiplication or *, i could be wrong though.

boat:SetPrimaryPartCFrame(boat.PrimaryPart.CFrame + Vector3.new(0,-1,0))

Adding a Vector3 to a CFrame translates it in absolute space. Multiplying it by another CFrame with no rotation will translate it in local space. (relative to the first CFrame’s orientation)

Consider using TweenService instead of a loop that gradually moves the part down. This will still only work on a single part so just as everyone else is saying you will still have to set a primary part and have the other parts welded to the primary part. But TweenService allows you to set parameters to define how long you want it to take to sink the boat.

Example:

local TweenService = game:GetService("TweenService")
local PrimaryPart = Boat.PrimaryPart -- Your boat

local TweenSettings = TweenInfo.new
(5, -- Number of seconds to sink
Enum.EasingStyle.Quad -- Easing Style
Enum.EasingDirection.Out -- Easing Direction
0 -- This number just defines how many times you want the tween to repeat.
false -- Do you want the tween to reverse? (I assume you don't want the boat to unsink).
0) -- Delay time

local EndGoal = {Position = PrimaryPart.Position - Vector3.new(0, -10, 0)} -- How far you want to sink.
local Sink = TweenService:Create(PrimaryPart, TweenSettings, EndGoal}

Sink:Play()

You can read more on TweenService here. It is extremely useful.

2 Likes