ProjectBorealis / PBCharacterMovement

HL2-style, classic FPS movement for Unreal Engine implemented in C++
https://www.projectborealis.com/movement
MIT License
1.25k stars 164 forks source link

Camera on uncrouch get too adjusted to capsule end #18

Closed Hevedy closed 2 years ago

Hevedy commented 4 years ago

When uncrouch the camera get too close to the end of the capsule, as result on collisions the camera ends inside meshes or on middle point.

A parameter to limit the distance between capsule half size and % between end could be a good point

mastercoms commented 4 years ago

This is in our internal code, but hasn't been pushed yet. We're currently heads down working on content, so we can't commit time to updating the open source version at this time.

azradric commented 2 years ago
void APBPlayerCharacter::RecalculateBaseEyeHeight()
{
    BaseEyeHeight = FMath::Lerp(GetDefault<APawn>(GetClass())->BaseEyeHeight, CrouchedEyeHeight, MovementPtr->CrouchAlpha);
}

In the DoCrouchResize:

CrouchAlpha = TargetAlpha;
OwnerRef->OnEndCrouch(HalfHeightAdjust, ScaledHalfHeightAdjust);  <- above this method call

In the DoUnCrouchResize:

CrouchAlpha = 1.0f - TargetAlpha;
OwnerRef->OnStartCrouch(HalfHeightAdjust, ScaledHalfHeightAdjust); <- above this method call

On both Crouch methods where it's returning and setting bInCrouch = false also add:

CrouchAlpha = 0;
mastercoms commented 2 years ago

Fixed in 74791cb2b465c5b1e0b3bd9beb91ac1d6accf570