How can I create a 'vertical treadmill' type movement?

Hello, I have a treadmill model, and I need to use RunService to move the parts in a rectangular motion around the base. I have already tried many things. like using math.cos, and math.sin.

Here are 2 examples:
This is what I would be working with:

,

This is how it should be rotating. The text ‘Base’ is the right side of the Treadmill base; if looking at it from the front direction indicator

Here is the example code block on a single treadmill to make sure the math is correct:

function QuestsManager:StartQuest1()
	print("Starting Quest 1 logic!")

	local basePart = workspace["QUEST 1"].Treadmills.Treadmill45.Base
	local platforms = workspace["QUEST 1"].Treadmills.Treadmill45.TweenParts:GetChildren()

	RunService.Heartbeat:Connect(function(dt)
		-- Math logic goes here --
	end)
end
   

Any help would be greatly appreciated, as I am not very efficient yet at complex math systems like this!

1 Like

This would not be easy to do the way I think you want to. It could be done and would be a lot like tank tracks. There are a few models with tank tracks you could look at but, again… not easy.
I’d be looking for a way to fake this. Maybe a top on the units I see here and boards going up or down by their own means, via tween or other script.

Conveyor Belt super simple flat version.
Conveyor Belt possible alternative.

The way you want it you would need to look into components like motors, constraints. VectorForce/Torque… mechanical parts. Well worth learning.

Assuming that this is some sort of climbing treadmill and those white part platforms move along the treadmill base…

Just addressing the positions,
Given your diagram, you want to move the parts along 4 paths at a certain rate and keep track of their progress. Have these paths’ directions be the LookVector and UpVector of the treadmill base part and their negatives.
A simple way to keep track of a part’s progress along a path is calculating their distance away from either an end point or starting point of a path and maybe comparing with the total length of the path. Which path the part is on should be kept track of and transitioned at the end of a path.
And so moving a platform would be, the starting position + direction * (progress or distance + rate).

For the rotations, they move along the base part so you would also use the look and up vectors to orient the parts along their path.
if you want to rotate at the corners with the rate, i might try using arc length to find an angle increment for axis angle rotation at a pivot.

as the other reply said, this isnt really trivial. if i only had to make this treadmill once and the treadmill doesnt change, i might go for animating the model instead.

1 Like

Hey, you think you could give me some sort of example possibly?

Sure. Here’s a picture

i’ll explain this later, if needed

1 Like

That makes a bit more sense.

So basically I would just loop through the platforms, and calculate the position of that platform of the current iteration, based on an end-point? And utilize UpVector, LookVector, and then for the back and down vector I would just ‘-’ the vector? So like -UpVector?

If you can, could you also give a code example possibly?

here’s some pseudocode to how i would set up a path and move a part along it.
this path goes along the front surface of the base part

local moveRate = 1 -- stud per second

local path = {
    StartPoint = Vector3...
    EndPoint = Vector3...
    Length = (StartPoint-EndPoint).Magnitude
    Direction = (EndPoint-StartPoint).Unit
    PathNormal = basePart.CFrame.LookVector -- used to orient the part on path
    NextPath = ...
}

local platforms = {}

local somePlatform = {
    Part = treadmill.PlatformPart,
    CurrentPath = path,

    Progress = (Part.Position - CurrentPath.StartPoint.Position).Magnitude 
    -- assuming the part positions are lined up with the endpoint and startpoint, 
    -- otherwise project onto the path's direction vector for this distance

}
platforms[1] = somePlatform

for _, platform in ipairs(platforms) do
    platform.Progress += moveRate * dt
    if platform.Progress > platform.CurrentPath.Length then
         platform.Progress -= platform.CurrentPath.Length
         platform.CurrentPath = platform.CurrentPath.NextPath -- assuming it didnt move beyond the next path too
    end

    platform.Part.CFrame = CFrame.lookAlong(
         platform.CurrentPath.StartPoint + platform.CurrentPath.Direction * platform.Progress, 
         platform.CurrentPath.Direction,
         platform.CurrentPath.PathNormal
    )

end

as for deciding which path a part starts on, i would manually assign it if theres not too many parts.
otherwise i might do some plane checks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.