Skip to content

Commit

Permalink
Ensure physics properly update when losing contact to the ground
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Feb 3, 2024
1 parent d8de61d commit 5e8bb2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions Code/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,16 +1020,15 @@ void CPlayer::ProcessRoomscaleMovement()
if (GetLinkedVehicle() || m_stats.isOnLadder || !GetEntity()->GetPhysics())
return;

if (m_stats.inRest <= 0 || m_stats.jumped) // don't do this while we are otherwise moving, or it will interfere
if (m_stats.inRest <= 0 || m_stats.jumped || m_stats.onGround <= 0) // don't do this while we are otherwise moving, or it will interfere
return;

if (m_roomscaleMovementPause > 0)
{
// only process roomscale movement at a reduced rate - the physics engine needs time to update the player before we
// manually set its position again, otherwise we are bypassing all physics
m_roomscaleMovementPause -= gEnv->pTimer->GetFrameTime();
if (m_roomscaleMovementPause > 0)
return;
--m_roomscaleMovementPause;
return;
}

Ang3 angles = GetEntity()->GetWorldAngles();
Expand Down Expand Up @@ -1066,7 +1065,7 @@ void CPlayer::ProcessRoomscaleMovement()
{
Vec3 ground = FindGround(desiredPos);
GetEntity()->SetPos(ground);
m_roomscaleMovementPause = 0.03f;
m_roomscaleMovementPause = 1;
}

gVR->UpdateReferenceOffset(hmdOffset);
Expand Down
2 changes: 1 addition & 1 deletion Code/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ class CPlayer :
void DebugGraph_AddValue(const char* id, float value) const;

private:
float m_roomscaleMovementPause = 0;
int m_roomscaleMovementPause = 0;
};


Expand Down

0 comments on commit 5e8bb2e

Please sign in to comment.