Falling off moving platform that's using tweened PrismaticConstraint/AlignPosition

I’ve been trying to get a moving platform to work properly using both PrismaticConstraints and AlignPositions, but regardless of what I do after about 15 seconds or so the character randomly falls off and can’t get back on again. (Video below)

Does anyone know why this might be happening? Thanks in advance.

Code:

local tweenService = game:GetService("TweenService")

local part = workspace:WaitForChild("Part")
local attach0 = Instance.new("Attachment")
attach0.CFrame = CFrame.new()
attach0.Parent = part

local attach1 = Instance.new("Attachment")
attach1.CFrame = part.CFrame
attach1.Parent = workspace.Terrain

local pris = Instance.new("PrismaticConstraint")
pris.ActuatorType = Enum.ActuatorType.None
pris.Attachment0 = attach1
pris.Attachment1 = attach0
pris.Speed = math.huge
pris.Parent = part

part.Anchored = false

tweenService:Create(attach1, TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), { CFrame = part.CFrame * CFrame.new(0, 0, 100) }):Play()


^ As you can see, it works fine for a few seconds and then suddenly stops working completely.

I think a simpler way to do this is by using AlignPosition to move the Platform instead of tweening.

Why are you using a PrismaticConstraint, an AlignPosition, and a tween?
Just use a PrismaticConstraint by itself.

I made a model for someone else who was having issues with a platform:

And you don’t have to add the Attachments or PrismaticConstraint (plus it’s Properties) using a script.

Why not use Physics, I am pretty sure the player automatically sticks to the object if Physics are applied.

That is only the case if the platform is being Moved by something like a VectorForce, AlignPosition or LinearVelocity.

Why don’t they just use AlignPosition?

Because not everyone knows that AlignPosition just puts a force on the object (also the name is kind of misleading).

I’m making a platform system that follows a path calculated using A* pathfinding and bezier curves to smoothen the movement, I guess the closest thing you could compare it to is a ship/train system. I used EgoMoose’s Platformer movement as a reference. (Platformer movement - Roblox)

I did, same thing happened, see the title.

Ah, k.
You don’t want to CFrame a Part and expect a player to stay on it, unless you weld the player to the platform.
Since you’re using a bezier curve system then you can’t use a PrismaticConstraint, unless you use 2 of them and move one on the X axis with it attached to another on the Z axis.

Yeah that’s why I avoided using CFrames, CFraming the attachment should work and it does but only for about 15 seconds before it suddenly stops working. It drags me along perfectly fine using the setup I presented in my original post but doesn’t work for long.

Before this I was “welding” the character to the moving parts similarly to Tyridge77’s train system by setting the HRP’s CFrame to that of the relative position between the object and player, but the downside of that is that other plays “lag” behind due to delay in replication, the higher the ping the further they lag behind.

You said it follows a path, but mentioned bezier curves. I only see the Part moving in a straight line.
You can change the PrismaticConstraint’s LinearResponsiveness to damp the movement.

Oh the video was just to demonstrate the issue, it happens regardless of the direction or speed. I was trying to fix the issue on a smaller scale first by having a part just move on one axis.

Take a copy of my platform Model and have a look at that.

I have, the issue is that I can’t do it the way you did because the part has to follow a strict pre-defined path, hence why in my example I tweened it because it repeatedly updates the goal position, as it would in the full system I have prepared that do involve curves and pathfinding. I am creating a ship system that people can stand on to sail around that follows either a manually created path or one it automatically creates during runtime using A* pathfinding, and it smoothly sails along it using n point bezier curves.

The image below shows the path markers for my test setup it’d have to follow, while smoothly interpolating between them using said curves.

Okay, I figured it out, the issue seems to have been that the network ownership was automatically set to the nearest player after a few seconds, which completely halted the physics updates of the object. I used :SetNetworkOwner(nil) and it worked. Thanks everyone.

1 Like

If the players lag behind you’re not doing it right. There should be no reason for any odd movement lag or jitter

1 Like

Well I am using the code you shared with badcc and us in the aforementioned thread, it works perfectly fine for the local player (aka your client) but other players still jitter due to replication delay. I had issues “welding” other players to the platform locally as specified in the quote below, probably because I misunderstood it. If you have time, could you elaborate on it?

For anchoring other players, it’s a tiny bit harder but still pretty straight forward.

We essentially have a relative cframe from the center of the train car on the server and, after trains are cframed, have your client take that info, loop through other players and if they’re on a train then set their hrp.cframe to trainroot * relativecframe(the one sent from the server)