Hey everyone!
I’m currently working on a study project - an FPS game with mechanics similar to Deus Ex: Human Revolution.
Right now, I’ve implemented a simple prototype of a CoverComponent, but the core logic is still quite rough.
Here is my current implementation:
void UCoverComponent::TryTakeCover()
{
ICoverInterface* CoverInterface = Cast<ICoverInterface>(GetOwner());
if (!CoverInterface || !CoverInterface->bIsCanTakeCover() || !CalculateCoverBorders(CurrentCoverPoint))
return;
bIsInCover = true;
CoverInterface->OnCoverTaken(CurrentCoverPoint);
OnCoverFound.Broadcast(CurrentCoverPoint);
}
void UCoverComponent::LeaveCover()
{
ICoverInterface* CoverInterface = Cast<ICoverInterface>(GetOwner());
if (!bIsInCover || !CoverInterface)
return;
CurrentCoverPoint = FCoverPoint{};
bIsInCover = false;
CoverInterface->OnCoverLeft();
OnCoverLost.Broadcast();
}
bool UCoverComponent::TraceCover(FCoverPoint& CurrentPoint)
{
FCollisionQueryParams Params;
Params.AddIgnoredActor(GetOwner());
FVector OwnerLoc = GetOwner()->GetActorLocation();
FVector ForwardVec = GetOwner()->GetActorForwardVector();
FVector CoverLoc = OwnerLoc + ForwardVec * SearchRadius;
FHitResult HitResult;
bool bIsHit = GetWorld()->LineTraceSingleByChannel(
HitResult,
OwnerLoc,
CoverLoc,
ECollisionChannel::ECC_Visibility,
Params
);
if (bIsHit)
{
AActor* HitActor = HitResult.GetActor();
if (HitActor && HitActor->ActorHasTag(TEXT("Cover")))
{
CurrentPoint.CoverActor = HitActor;
CurrentPoint.Location = HitResult.ImpactPoint + HitResult.ImpactNormal * OffsetFromCover;
CurrentPoint.ImpactNormal = HitResult.ImpactNormal;
return true;
}
}
return false;
}
void AMainCharacter::OnCoverTaken(const FCoverPoint& CoverPoint)
{
CoverState = EPlayerState::InCover;
CurrentCoverPoint = CoverPoint;
GetCharacterMovement()->StopMovementImmediately();
FRotator CoverRotation = (-CoverPoint.ImpactNormal).Rotation();
CoverRotation.Pitch = 0.f;
CoverRotation.Roll = 0.f;
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
TeleportTo(CoverPoint.Location, CoverRotation);
GetMesh()->SetOwnerNoSee(true);
ShadowMesh->SetOwnerNoSee(false);
CameraBoom->bDoCollisionTest = false;
CameraBoom->TargetArmLength = 200.0f;
WeaponComp->DestroyWeapon();
WeaponComp->SpawnWeapon(ShadowMesh, TEXT("WeaponSocket"));
}
void AMainCharacter::OnCoverLeft()
{
GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_Walking);
WeaponComp->DestroyWeapon();
WeaponComp->SpawnWeapon(GetMesh(), TEXT("WeaponSocket"));
bUseControllerRotationPitch = true;
bUseControllerRotationYaw = true;
bUseControllerRotationRoll = false;
GetMesh()->SetOwnerNoSee(false);
ShadowMesh->SetOwnerNoSee(true);
CoverState = EPlayerState::Idle;
CurrentCoverPoint = FCoverPoint{};
CameraBoom->bDoCollisionTest = true;
CameraBoom->TargetArmLength = 40.0f;
}
I’m using two meshes: one for first-person arms one full-body mesh for third-person view (similar to Deus Ex: HR)
The problem is:
when I take cover, the third-person mesh starts trembling.
I tested removing the Animation Blueprint from the third-person mesh and assigning a static animation and the trembling stops.
So I assume the issue is related to my Animation Blueprint.
Has anyone encountered something similar or can point me in the right direction?
Thanks in advance!


