These days I was trying to create a server-client entity system for my TD game. I used BezierPath, an easy to use and optimized spline path module for TD games and general paths
module to create the movement of my entities, but after some time I observer that is very problematic to create some effects like stun, slow, knockback.
(I was strying to change the start time, but it’s awful…)
I’d like if someone can give me some advices how can I implement this movement of entities, I have table with entities on server side, and also I create one on client, where I kepp info like position, hp, id, model etc.
Also it’s very important to allow entites to move circle-like, not only straight lines.
for id, entitySaved in pairs(SavedEntities) do
if entitySaved.Speed ~= 0 then
local elapsedTime = workspace:GetServerTimeNow() - tonumber(entitySaved.StartTime)
local progress = elapsedTime / (Length / tonumber(entitySaved.Speed))
local newCframe = newPath:CalculateUniformCFrame(progress)
entitySaved["Model"]:PivotTo(newCframe)
entitySaved.OldStartTime = entitySaved.StartTime
entitySaved.Progress = progress
else
if entitySaved.StartTime ~= entitySaved.OldStartTime then
entitySaved.OldStartTime = entitySaved.StartTime
local elapsedTime = workspace:GetServerTimeNow() - tonumber(entitySaved.StartTime)
local progress = elapsedTime / (Length / tonumber(entitySaved.OrigSpeed))
local newCframe = newPath:CalculateUniformCFrame(progress)
entitySaved["Model"]:PivotTo(newCframe)
entitySaved.OldStartTime = entitySaved.StartTime
entitySaved.Progress = progress
else
local oldNewCframe = newPath:CalculateUniformCFrame(entitySaved.Progress)
entitySaved["Model"]:PivotTo(oldNewCframe)
end
end
end
I was check this on the server every hearbeat.