#I am not staying on the moving platform

13 messages · Page 1 of 1 (latest)

potent marten
#

here is script:

potent marten
#

Idk what is wrong

#

why am I not staying at the platform when it is moving

dusty mortar
#

You never asked the script to make you stay. It isnt a feature in roblox studio

reef tendon
#

maybe use prismatic constraints

round dragonBOT
#

studio** You are now Level 2! **studio

robust owl
#

Align position should work

potent marten
#

how

valid whale
#

but you should add some mathmetical calculations

potent marten
#

ok

valid whale
#
-- by sigmatech
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local myPart = your_part
local goalCFrame = CFrame.new(your_goal)
local tweenDuration = your_duration
local easingStyle = your_easingStyle
local easingDirection = your_easingDirection

local _alpha = 0
local _startingCFrame = myPart.CFrame

local function onRenderStepped(deltaTime)
    -- Calculate new alpha (0-1) based on deltaTime
    _alpha += (deltaTime / tweenDuration)
    _alpha %= 1 -- This will wrap alpha back to 0 when it hits 1

    -- Get α` (alphaPrime) from TweenService:GetValue()
    local alphaPrime = TweenService:GetValue(_alpha, easingStyle, easingDirection)

    -- Linear interpolation of new CFrame based on alphaPrime
    local newCFrame = _startingCFrame:Lerp(goalCFrame, alphaPrime)

    -- Change velocities on parts to influence physics on parts touching the moving part
    -- here lies a bunch of math I solved and tested for you. (you're welcome)
    local velocity = (newCFrame.Position - myModel:GetPivot().Position) * (1/deltaTime)
    local angularVelocity = Vector3.new((myModel:GetPivot():ToObjectSpace(newCFrame)):ToEulerAngles()) * (1/deltaTime)
    myPart.AssemblyLinearVelocity = velocity
    myPart.AssemblyAngularVelocity = angularVelocity

    -- now set the cframe of your part!
    myPart.CFrame = newCFrame
end

-- To start:
RunService:BindToRenderStep("Tween", 99, onRenderStepped)

-- To stop:
RunService:UnbindFromRenderStep("Tween")
valid whale