Hi, I am creating a platformer game and have a system for moving platforms. They are moved with physics (NOT TWEENING) via AlignPosition. However, if platforms are fast, the player slides around and falls off instead of moving with them.
Things I have tried:
Increasing the density of the platform and the player
Increasing friction
This post (This one had the best results but unfortunately using tweening resulted in glitchy behavior while colliding with the platform in any other way than the top of it. The player did not carry the platform’s velocity when exiting it either)
I just cannot seem to get this to function properly. If anybody could help me out, it would be greatly appreciated.
local distance = (before.Position - after.Position).Magnitude
local att = Instance.new("Attachment")
att.Parent = controlPrimary
local pos = Instance.new("AlignPosition")
pos.MaxForce = math.huge
pos.Mode = Enum.PositionAlignmentMode.OneAttachment
pos.Responsiveness = math.huge
pos.Position = before.Position
pos.Attachment0 = att
pos.Enabled = true
pos.Parent = controlPrimary
controlPrimary.Anchored = false
if not rotatorFound then
local rot = Instance.new("AlignOrientation")
rot.Mode = Enum.OrientationAlignmentMode.OneAttachment
rot.RigidityEnabled = true
rot.Attachment0 = att
rot.Enabled = true
rot.Parent = controlPrimary
end
local switch = false
local function loop()
if stopDuration then
if moveSound then
moveSound:Stop()
end
task.wait(stopDuration)
if moveSound then
moveSound:Play()
end
end
local usedDuration
if switch then
usedDuration = outDuration or duration
pos.Position = before.Position
else
usedDuration = inDuration or duration
pos.Position = after.Position
end
pos.MaxVelocity = distance / usedDuration
switch = not switch
currentTask = task.delay(usedDuration, loop)
end
currentTask = task.spawn(loop)