Keep player smooth on moving platform?

Problem:

I’m currently making a Hot Air Balloon. The only issue is that the camera shakes a lot, how can I make it look smoother?

Balloon CFrame, Code:

--// Server
function TweenModelToNode(Model, Node, TravelTime)
	if not Model.PrimaryPart then 
		return warn("Model must have a PrimaryPart set.", Model)
	end
	
	local TargetCFrame = CFrame.new(Node.Position.X, Node.Position.Y, Node.Position.Z)
	local TargetCFrameOrientation = CFrame.Angles(Node.Orientation.X, math.rad(Node.Orientation.Y), Node.Orientation.Z)
	
	local StartTick = tick()
	local StartCFrame = Model.PrimaryPart.CFrame
	
	while true do
		RunService.Heartbeat:Wait()
		local SecondsElapsed = tick() - StartTick
		local Alpha = SecondsElapsed / TravelTime
		local CurrentCFrame = StartCFrame:Lerp(TargetCFrame * TargetCFrameOrientation, Alpha)
		Model:SetPrimaryPartCFrame(CurrentCFrame)
		if (CurrentCFrame.Position - TargetCFrame.Position).Magnitude < .1 then
			Model:SetPrimaryPartCFrame(TargetCFrame)
			break
		end
	end
end

Stay on balloon platform, code:

--// Client
local Player = game.Players.LocalPlayer
local RunService = game:GetService('RunService')
local LastAirBallonCFrame
local Function
local Function2

Function = RunService.Heartbeat:Connect(function()
	local RootPart = Player.Character.LowerTorso
	local Ignore = Player.Character
	local ray = Ray.new(RootPart.CFrame.p,Vector3.new(0,-50,0))
	local Hit, Position, Normal, Material = workspace:FindPartOnRay(ray,Ignore)
	if Hit and Hit.Name == "Platform" then
		local Platform = Hit
		if LastAirBallonCFrame == nil then
			LastAirBallonCFrame = Platform.CFrame
		end
			local PlatformCF = Platform.CFrame 
			local Rel = PlatformCF * LastAirBallonCFrame:inverse()
			LastAirBallonCFrame = Platform.CFrame
			RootPart.CFrame = Rel * RootPart.CFrame
		else
			LastAirBallonCFrame = nil
		end
		Function2 = Player.Character.Humanoid.Died:Connect(function()
		Function:Disconnect()
		Function2:Disconnect()
	end)
end)
2 Likes

The effect of the camera “Shaking” is a result of the players camera updating from large distance from one place to another very frequently, to stop this either slow down the speed of your hot air balloon or make it more “smooth”

1 Like

you could make the camera orbit around the air balloon instead of the player. (when the player enters the balloon) this will resolve your issue and is probably more satisfying.

mid-way down there is a code snippet for ‘rotating around objects’

Side Note

also you’ll probably want to use body position/gyro for the movement it’ll take physics into consideration and make the player stay on the platform easier. (atleast that’s what I’ve heard)

1 Like

You could look to incorporate the wall stick controller by EgoMoose if you like. It might take some time getting used to it and implementing it in your game but it has great results and is definitely applicable to your balloon.

1 Like

I tried to do it using body position and gyro, but I’m not quite sure how to use them in this situation. I do not understand the explanation on the wiki either.

Slowing down does fix it, but I’d love to have it working while it’s going as fast as it is in the video. (while still being able to walk)

instead of manipulating the parts CFrame you would just manipulate the body gyro/position CFrame, and its okay though I think the camera changes alone will help your issue.

1 Like

If you want to keep speed and smoothness you should try using the physics engine to move your models such as BodyForce e.g and have the player sat on a Seat while the model is moving

Maybe this will help you out.

1 Like

I actually used that code for the client :slight_smile: (the problem is probably the method of how quickly I move the air balloon which makes it jiggering to the camera)

Oh sorry I just noticed.

Wait2008 mentioned before to have the player seated when the balloon is moving at that speed. I think that’s a good solution if you cant manage to fix this problem.

1 Like