Skip to content

Commit

Permalink
correct head angle pitch when looking at peds
Browse files Browse the repository at this point in the history
for example at the end of the mission High Noon, Mario will now correctly look at Pulaski instead of looking upwards
  • Loading branch information
headshot2017 committed Feb 9, 2024
1 parent d8cfa31 commit f9a4a05
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions mario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,17 @@ void marioTick(float dt)
// part 2: pitch
if (!ped->m_nPedFlags.bInVehicle)
{
float dist = DistanceBetweenPoints(CVector2D(marioCurrPos), CVector2D(targetPos)) * 2.f;
int Zsign = -sign(targetPos.z - marioCurrPos.z);
RwV3d headPosRw = targetPos.ToRwV3d();
if (lookAt->m_bEntityExist && lookAt->m_pEntity->m_nType == ENTITY_TYPE_PED)
{
const auto hier = GetAnimHierarchyFromSkinClump(lookAt->m_pEntity->m_pRwClump);
if (hier)
headPosRw = *RwMatrixGetPos(&RpHAnimHierarchyGetMatrixArray(hier)[RpHAnimIDGetIndex(hier, BONE_HEAD)]);
else
((CPed*)lookAt->m_pEntity)->GetBonePosition(headPosRw, BONE_NECK, false);
}
float dist = DistanceBetweenPoints(CVector2D(marioCurrPos), CVector2D(headPosRw)) * 2.f;
int Zsign = -sign(headPosRw.z - marioCurrPos.z);
headAngleTarget[0] = (dist) ? (M_PI_2 * Zsign) / dist : 0;
if (headAngleTarget[0] < -M_PI || headAngleTarget[0] > M_PI) headAngleTarget[0] = 0;
}
Expand Down

0 comments on commit f9a4a05

Please sign in to comment.