Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@alanedwardes
Last active March 27, 2022 02:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanedwardes/aba1ad897b94d02a0fe3033fb48c8d42 to your computer and use it in GitHub Desktop.
Save alanedwardes/aba1ad897b94d02a0fe3033fb48c8d42 to your computer and use it in GitHub Desktop.
A client-side smooth crouching implementation for Unreal Engine 4.
void AEstPlayer::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
UpdateCamera(DeltaSeconds);
}
void AEstPlayer::UpdateCamera(float DeltaSeconds)
{
FVector EyeLocation;
FRotator EyeRotation;
GetActorEyesViewPoint(EyeLocation, EyeRotation);
auto Interp = FMath::VInterpTo(Camera->RelativeLocation, EyeLocation, DeltaSeconds, 24.f);
Camera->SetRelativeLocation(Interp);
Camera->SetRelativeRotation(EyeRotation);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment