Skip to content

Commit

Permalink
Make immersive ladder climbing more reliable, especially climbing down
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Aug 27, 2023
1 parent ec8d107 commit 0550536
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,7 @@ int CScriptObjectPlayer::UseLadder(IFunctionHandler *pH)
m_pPlayer->SetProneSpeed(m_fSpeedProne);
}

if (gVR->vr_immersive_ladders && m_pPlayer->m_activeHandGrabbingLadder != -1)
if (gVR->vr_immersive_ladders)
{
// stick to ladder until player lets go
m_pPlayer->m_insideLadderVolume = false;
Expand Down
15 changes: 12 additions & 3 deletions Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,12 @@ void CPlayer::ProcessMovements(CXEntityProcessingCmd &cmd, bool bScheduled)

//FIXME: would be nice if backward key detach us from the ladder when we approach the ground (instead use the jump button), but for this
//more info about the ladder are needed, like the center position, to know if we are going up or down.
if (m_stats.onLadder)
{
speedxyz[0] -= -m_psin*.3f*fBack;
speedxyz[1] -= m_pcos*.3f*fBack;
}
else
{
speedxyz[0] -= -m_psin*fBack;
speedxyz[1] -= m_pcos*fBack;
Expand Down Expand Up @@ -1926,13 +1932,16 @@ void CPlayer::ProcessMovements(CXEntityProcessingCmd &cmd, bool bScheduled)
}
m_wasGrabbingLadder[i] = grabbing[i];
}
if (m_activeHandGrabbingLadder != -1 && !grabbing[m_activeHandGrabbingLadder])

Vec3 distFromLadder = m_pEntity->GetPos() - m_vLadderPosition;
distFromLadder.z = 0;
if (m_activeHandGrabbingLadder != -1 && (!grabbing[m_activeHandGrabbingLadder] || distFromLadder.Length() > 2.f))
{
m_activeHandGrabbingLadder = -1;
CheckLadderDismount();
}

if (m_activeHandGrabbingLadder == -1 && !m_insideLadderVolume)
if (m_activeHandGrabbingLadder == -1 && !m_insideLadderVolume && distFromLadder.Length() > 0.8f)
{
// no longer inside ladder volume and not grabbing, so let go
m_stats.onLadder = false;
Expand Down Expand Up @@ -2495,7 +2504,7 @@ void CPlayer::ProcessRoomscaleMovement(CXEntityProcessingCmd& ProcessingCmd)
if (!ProcessingCmd.UseMotionControls())
return;

if (GetVehicle() || m_pMountedWeapon || (m_stats.onLadder && gVR->vr_immersive_ladders))
if (GetVehicle() || m_pMountedWeapon || m_stats.onLadder)
return;

Ang3 angles = m_pEntity->GetAngles();
Expand Down

0 comments on commit 0550536

Please sign in to comment.