How would I go about keeping Characters on Tweening Platforms?

I have an assembly line/factory whatever you want to call it that uses Welded parts and TweenService, and I’m trying to look into smooth and performance friendly options to keep a player’s Character on the platform whilst it’s moving

While the system I have works, it has some slight performance and visual drawbacks. The camera always tends to be slightly offset when the platform is in motion, this is extremely apparent when fast and sudden movements happen, the camera tends to offset.

Several solutions have gone into testing, setting the velocity of the character, using different RenderStepped functions, and using :BindToRenderStep with a priority ranging between 0 and 300, which hasn’t helped. I’ve played games like Jailbreak where they have a similar system to keep your character on the train/plane, which theirs works absolutely flawlessly. I’ve read the DevForum post about the Jailbreak Train Platform Script, it’s the same one I’m using now which has the issues above.

local function BindCharacterToModels()
	local RayCast = Ray.new(RootPart.CFrame.Position, Vector3.new(0, -50, 0))
	local Hit, Position, Normal, Material = workspace:FindPartOnRay(RayCast, Ignore)
	if Hit and Hit.Name == "HitBox" then 
		local TweeningPart = Hit
		if not LastCFrame then 
			LastCFrame = TweeningPart.CFrame 
		end
		local PartCFrame = TweeningPart.CFrame 
		local Rel = PartCFrame * LastCFrame:Inverse()
		LastCFrame = TweeningPart.CFrame 
		RootPart.CFrame = Rel * RootPart.CFrame 
	else
		LastCFrame = nil 
	end
end
RunService:BindToRenderStep("CharacterBindFunction", 200, BindCharacterToModels)

Late response, but worth giving a response anyways.

TweenService seems to be deferred after connections, which is weird but whatever.
This means you need to use task.defer, meaning you need to add it within the BindToCharacterToModels function. In order to solve the camera issue, I move the camera along with the character so that it isn’t snappy. In order to get the player not to fall off aswell, I applied the platform offset to check where to cast the ray.

I linked a place file below.
TweenServicePlatform.rbxl (36.3 KB)

3 Likes

Thanks a lot man, solved the issue completely on my end

1 Like