Forum > Coding >

How to make a ridable ship on skinned mesh ocean?

Posts: 17

Threads: 10

Joined: Jan, 2021

Reputation: 0

Posted

I made a wave system using skinned mesh and managed to make the boat float on it, but I'm having problems making the ship controllable while floating. Here is the code to make it float:

local Object = workspace:WaitForChild("Pirate")
local module = require(game:GetService("ReplicatedStorage"):WaitForChild("Wave"))
local rs = game:GetService("RunService")
local main = Object.primary

rs.Heartbeat:Connect(function(DeltaTime)
	local PlatformCF = main.main.CFrame
	local PlatformPosition = PlatformCF.Position

	local BackPosition = (PlatformCF * main.back.CFrame).Position
	local FrontPosition = (PlatformCF * main.front.CFrame).Position
	local LeftPosition = (PlatformCF * main.left.CFrame).Position
	local RightPosition = (PlatformCF * main.right.CFrame).Position

	BackPosition = Vector3.new(BackPosition.X, module.GetHeightAtXZ(BackPosition), BackPosition.Z)
	FrontPosition = Vector3.new(FrontPosition.X, module.GetHeightAtXZ(FrontPosition), FrontPosition.Z)
	LeftPosition = Vector3.new(LeftPosition.X, module.GetHeightAtXZ(LeftPosition), LeftPosition.Z)
	RightPosition = Vector3.new(RightPosition.X, module.GetHeightAtXZ(RightPosition), RightPosition.Z)

	local FinalCFrame = CFrame.new((BackPosition + FrontPosition + LeftPosition + RightPosition) / 4, (FrontPosition + RightPosition) / 2)
	Object:PivotTo(FinalCFrame)
end)

 

  • 0

I’m not lazy, I’m just on energy saving mode.

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )