void APlayerCharacter::FadeToWhite() { DistanceToX = GetDistanceTo(WhereBeAnna); if (DistanceToX > 50) { GetFirstPersonCameraComponent()->PostProcessSettings.ColorOffset.X = 20 / DistanceToX; GetFirstPersonCameraComponent()->PostProcessSettings.ColorOffset.Y = 20/ DistanceToX; GetFirstPersonCameraComponent()->PostProcessSettings.ColorOffset.Z = 20 / DistanceToX; GetFirstPersonCameraComponent()->PostProcessSettings.ColorContrast.X = 1 - 20 / DistanceToX; GetFirstPersonCameraComponent()->PostProcessSettings.ColorContrast.Y = 1 - 20 / DistanceToX; GetFirstPersonCameraComponent()->PostProcessSettings.ColorContrast.Z = 1 - 20 / DistanceToX; } else { ShowTime = false; } }
// Check for bullet collisions void AMurphysLawCharacter::ComputeBulletCollisions() { // Only look for pawns FCollisionObjectQueryParams CollisionObjectQueryParams; CollisionObjectQueryParams.AddObjectTypesToQuery(ECollisionChannel::ECC_PhysicsBody); CollisionObjectQueryParams.AddObjectTypesToQuery(ECollisionChannel::ECC_Destructible); CollisionObjectQueryParams.AddObjectTypesToQuery(ECollisionChannel::ECC_WorldStatic); // Remove self from query potential results since we are the first to collide with the ray FCollisionQueryParams RayQueryParams; RayQueryParams.AddIgnoredActor(this); // Ray starting coordinates const FVector CollisionRayStart = GetFirstPersonCameraComponent()->GetComponentLocation(); const FVector CollisionRayInitialDirection = GetFirstPersonCameraComponent()->GetComponentTransform().GetRotation().GetAxisX(); // Group damage of touched objects together const float MaxFragmentDeviationRadian = FMath::DegreesToRadians(GetEquippedWeapon()->GetMaxFragmentDeviationAngle(IsCharacterAiming)); bool AtLeastOneHit = false; // Trace lines to detect pawn for (int32 i = 0; i < GetEquippedWeapon()->GetNumberOfEmittedFragments(); ++i) { // Ray ending coordinates const FVector CollisionRayAngledDirection = FMath::VRandCone(CollisionRayInitialDirection, MaxFragmentDeviationRadian); const FVector CollisionRayEnd = CollisionRayStart + (CollisionRayAngledDirection * GetEquippedWeapon()->GetMaxTravelDistanceOfBullet()); FHitResult CollisionResult; bool HasHit = GetWorld()->LineTraceSingleByObjectType(CollisionResult, CollisionRayStart, CollisionRayEnd, CollisionObjectQueryParams, RayQueryParams); if (HasHit) { // Simple damage amount considering the distance to the target depending on the bone hit float DeliveredDamage = GetDeliveredDamage(CollisionResult); FPointDamageEvent CollisionDamageEvent(DeliveredDamage, CollisionResult, CollisionRayAngledDirection, UDamageType::StaticClass()); // If the actor we hit is a hittable actor and an enemy, we have at least one hit so we'll show the Hit Marker if (IsHittableActor(CollisionResult.GetActor()) && !MurphysLawUtils::IsInSameTeam(CollisionResult.GetActor(), this)) { AtLeastOneHit = true; } if (Role == ROLE_Authority) { CollisionResult.GetActor()->TakeDamage(DeliveredDamage, CollisionDamageEvent, GetController(), this); } else { Server_TransferDamage(CollisionResult.GetActor(), DeliveredDamage, CollisionDamageEvent, GetController(), this); } } } // If there was at least one hit, we show the HitMarker if (AtLeastOneHit) { auto MyController = Cast<AMurphysLawPlayerController>(GetController()); if (MyController != nullptr && MyController->GetHUDInstance() != nullptr) { MyController->GetHUDInstance()->ShowHitMarker(); } } }
void APlayerCharacter::UpdateCamera(float Counter) { if (Counter == 0) { GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation = 1; GetFirstPersonCameraComponent()->PostProcessSettings.VignetteIntensity = 0; } else if (Counter == 1) { if (GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation < 1.2) { GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation += 0.005; GetFirstPersonCameraComponent()->PostProcessSettings.VignetteIntensity += 0.0025; } else { GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation = 1.2; GetFirstPersonCameraComponent()->PostProcessSettings.VignetteIntensity = 0.1; CameraIsChanging = false; } } else if (Counter == 2) { if (GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation < 1.4) { GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation += 0.005; GetFirstPersonCameraComponent()->PostProcessSettings.VignetteIntensity += 0.0025; } else { GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation = 1.4; GetFirstPersonCameraComponent()->PostProcessSettings.VignetteIntensity = 0.2; CameraIsChanging = false; } } else if (Counter > 2) { if (GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation < 1.6) { GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation += 0.005; GetFirstPersonCameraComponent()->PostProcessSettings.VignetteIntensity += 0.0025; } else { GetFirstPersonCameraComponent()->PostProcessSettings.FilmSaturation = 1.6; GetFirstPersonCameraComponent()->PostProcessSettings.VignetteIntensity = 0.3; CameraIsChanging = false; } } }