UE4 – Tip of the Day 1: Camera FadeIn/FadeOut

Did you know…

You can create camera fade effects (fadein/fadeout) very easy using StartCameraFade function from PlayerCameraManager !

Example: Let’s create an function in our PlayerController to start a Fadeout effect and then restart the level

void AMyPlayerController::StartFadeOutAndRestartLevel()
	// Check if PlayerCameraManager is valid
	if (PlayerCameraManager)
		// Start Fading out (the fade will take 3 seconds)
		const float Duration = 3.0f;
		PlayerCameraManager->StartCameraFade(0.f, 1.f, Duration, FLinearColor::Black, false, true);

		// and after 3 seconds, restart level
		FTimerHandle TimerHandle;
		GetWorldTimerManager().SetTimer(TimerHandle, this, &APlayerController::RestartLevel, Duration, false);

… and we have a lot of parameter to set up the fade effect:

FromAlpha: Alpha at which to begin the fade. Range [0..1], where 0 is fully transparent and 1 is fully opaque solid color.
ToAlpha: Alpha at which to finish the fade.
Duration: How long the fade should take, in seconds.
Color: Color to fade to/from.
bShouldFadeAudio: True to fade audio volume along with the alpha of the solid color.
bHoldWhenFinished: True for fade to hold at the ToAlpha until explicitly stopped (e.g. with StopCameraFade)

The fade out effect is very useful in our game, a classic example is when our character die. StartCameraFade don’t remove the HUD, so, you will need to hide it before start the effect.


WARNING: English is not my first language, because of that, this translation may have some grammatical errors.

Note : This post has been developed using Unreal Engine 4.12.5 . If you are working with another version, you may find some differences since the engine is constantly updating. If so, leave me your comments at the end of the post and we’ll look for a solution together.

Spanish version: UE4 – Consejo del día 1: Efecto de FadeIn/FadeOut en la cámara

Fernando Castillo Coello
Follow me

Fernando Castillo Coello

Gameplay Programmer at GameOlic
I've been into games development with Unreal Engine since 2014 and want to share with you some of the tips and tricks that I learned during my journey.
Fernando Castillo Coello
Follow me

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>