Skip to content

Commit 744b0cb

Browse files
authored
Fix ped rotation sync is broken when using setElementFrozen instantly (#4566)
Simplify SetFrozen logic and ensure matrix consistency The `SetFrozen` method was simplified by removing conditional logic related to `m_pPlayerPed` and now always uses the cached `m_Matrix` to update `m_matFrozen`. This leverages the fact that `m_Matrix` is already updated by `SetCurrentRotation`. In `SetCurrentRotation`, added logic to always update the Z-axis rotation of `m_Matrix` when setting `fRotation`. This ensures `m_matFrozen` gets the correct value in `SetFrozen` and maintains consistency between the current rotation and the cached matrix.
1 parent b59f414 commit 744b0cb

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,21 +2012,8 @@ void CClientPed::SetFrozen(bool bFrozen)
20122012
m_pTaskManager->RemoveTask(TASK_PRIORITY_PHYSICAL_RESPONSE);
20132013
}
20142014

2015-
if (m_pPlayerPed)
2016-
{
2017-
m_pPlayerPed->GetMatrix(&m_matFrozen);
2018-
2019-
CVector vecFrozenRotation = m_matFrozen.GetRotation();
2020-
2021-
if (vecFrozenRotation.fX == 0.0f && vecFrozenRotation.fY == 0.0f && vecFrozenRotation.fZ == 0.0f)
2022-
{
2023-
m_matFrozen.SetRotation(m_Matrix.GetRotation());
2024-
}
2025-
}
2026-
else
2027-
{
2028-
m_matFrozen = m_Matrix;
2029-
}
2015+
// Always use the client's cached matrix, it's already updated by SetCurrentRotation
2016+
m_matFrozen = m_Matrix;
20302017
}
20312018
}
20322019
}
@@ -3366,6 +3353,11 @@ void CClientPed::SetCurrentRotation(float fRotation, bool bIncludeTarget)
33663353
if (bIncludeTarget)
33673354
m_fTargetRotation = fRotation;
33683355
}
3356+
3357+
// Always update m_Matrix rotation so m_matFrozen gets correct value in SetFrozen
3358+
CVector vecRotation = m_Matrix.GetRotation();
3359+
vecRotation.fZ = fRotation;
3360+
m_Matrix.SetRotation(vecRotation);
33693361
}
33703362

33713363
void CClientPed::SetTargetRotation(float fRotation)

0 commit comments

Comments
 (0)