Skip to content

Commit 96e4202

Browse files
committed
attempt to fix paused playbacks
1 parent 3e639ce commit 96e4202

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Server/Components/NPCs/Playback/playback.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,31 @@ bool NPCPlayback::process(NPC& npc, TimePoint now)
101101
{
102102
if (recordData_.playbackType == NPCPlaybackType::Driver)
103103
{
104-
npc.resetKeys();
104+
if (currentIndex_ < recordData_.vehicleData.size())
105+
{
106+
const auto& syncData = recordData_.vehicleData[currentIndex_];
107+
108+
npc.resetKeys();
109+
npc.setVelocity({ 0.0f, 0.0f, 0.0f }, false);
110+
npc.setPosition(syncData.Position, false);
111+
npc.setRotation(syncData.Rotation, false);
112+
113+
npc.sendDriverSync();
114+
}
105115
}
106116
else if (recordData_.playbackType == NPCPlaybackType::OnFoot)
107117
{
108-
npc.resetKeys();
118+
if (currentIndex_ < recordData_.onFootData.size())
119+
{
120+
const auto& syncData = recordData_.onFootData[currentIndex_];
121+
npc.resetKeys();
122+
npc.setVelocity({ 0.0f, 0.0f, 0.0f }, false);
123+
npc.setPosition(syncData.Position, false);
124+
npc.setRotation(syncData.Rotation, false);
125+
npc.resetAnimation();
126+
127+
npc.sendFootSync();
128+
}
109129
}
110130
startTime_ = now - recordData_.timeStamps[currentIndex_];
111131
return true;

0 commit comments

Comments
 (0)