Skip to content

Commit

Permalink
Improve roomscale movement on slopes; disable acceleration for stick …
Browse files Browse the repository at this point in the history
…movement
  • Loading branch information
fholger committed Sep 2, 2023
1 parent 6684347 commit b19cf68
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ void CPlayer::ProcessMovements(CXEntityProcessingCmd &cmd, bool bScheduled)
return;

m_hmdRefHeight = cmd.GetHmdRefHeight();
if (!m_pGame->IsMultiplayer())
//if (!m_pGame->IsMultiplayer())
{
// fixme: does not work well in multiplayer, probably needs some massaging with prediction
ProcessRoomscaleMovement(cmd);
Expand Down Expand Up @@ -2198,7 +2198,7 @@ void CPlayer::ProcessMovements(CXEntityProcessingCmd &cmd, bool bScheduled)
hike.iJump = bJump && !bNoGravity;
hike.dir=speedxyz;

DampInputVector(hike.dir,m_input_accel,m_input_stop_accel,true,false);
//DampInputVector(hike.dir,m_input_accel,m_input_stop_accel,true,false);

pPhysEnt->Action(&hike);

Expand Down Expand Up @@ -2519,6 +2519,20 @@ void CPlayer::ProcessRoomscaleMovement(CXEntityProcessingCmd& ProcessingCmd)
Vec3 offset = ProcessingCmd.GetHmdPos();
Vec3 worldOffset = playerTransform * offset;
worldOffset.z = 0;

// take terrain slope into account to move a bit up or down and prevent the engine from "jumping" the player vertically
if (m_pEntity->GetPhysics())
{
pe_status_living status;
m_pEntity->GetPhysics()->GetStatus(&status);
Vec3 normal = status.groundSlope;

Vec3 fwd = worldOffset.GetNormalized();
Vec3 left = -fwd.Cross(normal);
fwd = left.Cross(normal);
worldOffset = fwd * worldOffset.len();
}

Vec3 desiredPos = playerPos + worldOffset;

// fixme: the engine appears to do a good job of preventing the player from clipping into obstacles and getting up terrain slopes
Expand Down

0 comments on commit b19cf68

Please sign in to comment.