#I am not staying on the moving platform
13 messages · Page 1 of 1 (latest)
You never asked the script to make you stay. It isnt a feature in roblox studio
maybe use prismatic constraints
** You are now Level 2! **
Align position should work
how
the way you did is correct
but you should add some mathmetical calculations
ok
-- 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")
^