Good morning!
I am currently trying to achieve player footstep synchronisation for marching.
As in, I would like the animations for all players to play at the same time so their foot planting is synchronised.
I have tried to match the animation time position to a global time position so that all players are at the same time position in their animation, however this falls short (and I’m not 100% certain why)
The method I’m currently using is to edit the default “Animate” script, where I added the following lines:
At the top of the Animate script:
function Tick()
return DateTime.now().UnixTimestampMillis / 1000 -- Determine time across all clients
end
function WalkCycleCalc(Anim)
local TotalAnimLength = Anim.Length -- Length of walk anim
local CurrentTimeServer = Tick() -- Above function
local TimeSeperator = CurrentTimeServer/TotalAnimLength
local FractionalTime = TimeSeperator%1
local CurrentTime = TotalAnimLength*FractionalTime
return CurrentTime
-- Above 4 lines determine position of animation in correspondence with server time
end
Inside of the “switchToAnim” function inside the Animate script:
if animName == "walk" then
currentAnimTrack.TimePosition=WalkCycleCalc(currentAnimTrack)
-- If newly played animation is walk cycle, then set to synchronised time.
end
I have also attached a copy of the game for anyone who would like to have a look:
MarchingTesting.rbxl (80.5 KB)
Any questions, please ask. Any help would be greatly appreciated:)
Kind regards,
Bigclaphead