I’m using AlignPosition w/ 2 Attachments, 1 on the client-sided ball and the other iterating through a curve. My problem is that the movement is only smooth when on 60 fps, I was previously using a for loop and tried switching to runservice for deltaTime but that didn’t work.
Script:
(Commented Out are the two loops I tried)
local function PingPongVelocity(Ball, Time, SFX, P2)
--print("Start Velocity")
Ball.Anchored = false
local newVelocity = Ball:FindFirstChild("AlignPosition")
local BallAttachment = Ball:FindFirstChild("Att1")
local startTime = time()
local steps = 10
local speed = game.Workspace.ServerBalls:FindFirstChild(Ball.Name).Speed.Value
local duration = (Time - .25)
local delayPerStep = duration / steps
--for i = 1, steps do
-- newVelocity.Attachment1 = folder["Part"..i]:FindFirstChild("Attachment")
-- task.wait(delayPerStep)
--end
--local i = 1
--local conn
--conn = RunService.RenderStepped:Connect(function(dt)
-- if i == steps then
-- conn:Disconnect()
-- end
-- newVelocity.Attachment1 = folder["Part"..i]:FindFirstChild("Attachment")
-- i = i + 1
-- task.wait(delayPerStep * (dt*60))
--end)
local VFX = script.Attachment:Clone()
VFX.Parent = game.Workspace
VFX.Position = P2
VFX["Whole swirl"]:Emit()
game.Debris:AddItem(VFX, 1)
--print("TIME: " .. time() - startTime)
if SFX then
local sound = game.Workspace["Ping pong sound effect"]:Clone()
sound.Parent = Ball
sound:Play()
game.Debris:AddItem(sound, .5)
else
local sound = game.Workspace["ping pong hit sound"]:Clone()
sound.Parent = Ball
sound:Play()
game.Debris:AddItem(sound, .5)
end
--Ball.Anchored = true
end
240 FPS V. 60 FPS