2024-08-07 16:45:56 +00:00
|
|
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
2024-09-09 01:38:47 +00:00
|
|
|
local blink = require(ReplicatedStorage.net)
|
2024-08-07 16:45:56 +00:00
|
|
|
local std = require(ReplicatedStorage.std)
|
|
|
|
local world = std.world
|
2024-09-09 01:38:47 +00:00
|
|
|
local ref = std.ref
|
2024-08-07 16:45:56 +00:00
|
|
|
|
|
|
|
local cts = std.components
|
|
|
|
|
|
|
|
local Model = cts.Model
|
|
|
|
local Transform = cts.Transform
|
|
|
|
|
|
|
|
local function move(dt: number)
|
2024-10-12 20:18:11 +00:00
|
|
|
for _, transform, model in world:query(Transform, Model):iter() do
|
|
|
|
local cf = transform.new
|
|
|
|
if cf ~= transform.old then
|
|
|
|
local origo = model.PrimaryPart.CFrame
|
|
|
|
model.PrimaryPart.CFrame = origo:Lerp(cf, 1)
|
|
|
|
transform.old = cf
|
|
|
|
end
|
|
|
|
end
|
2024-08-07 16:45:56 +00:00
|
|
|
end
|
|
|
|
|
2024-09-09 01:38:47 +00:00
|
|
|
local function syncTransforms()
|
2024-10-12 20:18:11 +00:00
|
|
|
for _, id, cf in blink.UpdateTransform.Iter() do
|
|
|
|
local e = ref("server-" .. id)
|
|
|
|
local transform = e:get(cts.Transform)
|
|
|
|
if not transform then
|
|
|
|
continue
|
|
|
|
end
|
|
|
|
transform.new = cf
|
|
|
|
end
|
2024-09-09 01:38:47 +00:00
|
|
|
end
|
|
|
|
|
2024-08-21 15:57:40 +00:00
|
|
|
return function(scheduler: std.Scheduler)
|
2024-10-12 20:18:11 +00:00
|
|
|
local phases = scheduler.phases
|
|
|
|
local system_new = scheduler.systems.new
|
|
|
|
system_new(move, phases.Heartbeat)
|
|
|
|
system_new(syncTransforms, phases.RenderStepped)
|
2024-08-21 15:57:40 +00:00
|
|
|
end
|