← Learn library

Unreal Engine & Blueprints / Unreal Engine

Blueprint Basics Conditionals and Branches in Unreal Engine

Channel: CGI Nerd ·

Written guide

Original CGI Nerd video thumbnail
Blueprint Basics Conditionals and Branches in Unreal EngineCGI Nerd · Video hosted on YouTube

Playing loads YouTube content. YouTube processes data after activation.

Watch on YouTube

If the player is blocked or unavailable, use Watch on YouTube.

Software: Unreal Engine

Build a small Blueprint resource counter that decreases on a left click and resets on a right click. A Branch prevents the demonstrated decrement path from taking the resource below zero. The exercise separates three operations that are easy to confuse: comparing a value, choosing an execution path and assigning the changed value.

This is a historical Blueprint basics lesson using direct mouse-button events and an Actor that receives Player 0 input. The exact engine build is unverified. It demonstrates a local input exercise, not a complete resource-management or multiplayer system.

Give the placed Actor input and a starting resource

At 00:00, create an Actor Blueprint, place an instance in the level and open its Event Graph. At 01:02, set Auto Receive Input to Player 0 in the class defaults and add Left Mouse Button and Right Mouse Button events.

Create an integer variable named Resource. At 02:01, compile so its default value can be edited, then set that default to 5. The Actor instance is important: creating the Blueprint asset alone does not put this example’s input receiver into the level.

The default supplies the starting value. The right-click operation built next is an explicit assignment during play, so it can restore that value after the resource has changed.

Build the reset path first

At 02:01, connect the right-button press execution to Set Resource, with an input value of 5. Follow that with Print String and supply the resource value through the integer-to-string conversion shown in the source.

This path needs no condition because every right click has the same intended result. Repeated right clicks should keep printing five. They should not add another five each time.

Check both kinds of wire: execution determines when Set and Print run, while the value connection determines what is stored or displayed. Merely connecting a number to a node does not trigger the assignment.

Gate the decrement with a Boolean comparison

At 03:02, add a Branch to the left-click path. At 04:02, get the current Resource and compare it with one using greater than or equal to. Connect that Boolean result to the Branch condition and the left-button press to its execution input.

At 05:02, connect the True execution output to Set Resource. Its value comes from subtracting 1 from the current Resource. Then print the updated value after the assignment.

The relationship is:

Current resource Condition Resource >= 1 Action
5 True Store 4, then print 4
1 True Store 0, then print 0
0 False Keep 0 and print it

The comparison itself does not consume the resource. It decides which execution path is allowed to reach the assignment. Epic’s Branch documentation describes this separation between the Boolean input and the True/False execution outputs.

Give the false path an observable result

At 06:03, connect the False output to a separate Print String using the current resource. It bypasses the subtraction and Set node, so the exhausted state remains visible without changing it.

This protects the demonstrated decrement path starting from five. It is not a general clamp: if some other operation supplied a negative number, this false path would print that negative value rather than repair it. The lesson contains no such external mutation, so the observed exhausted state is zero.

Compile and play. Repeated left clicks should show 4, 3, 2, 1, 0, 0. Right-clicking should print five. At 07:01, the instructor also resets partway through depletion, confirming that reset does not require reaching zero first.

If the count changes incorrectly, check whether the print follows the assignment, whether subtraction reads the current variable and whether only the True branch reaches Set. If nothing responds, check the placed Actor and its input configuration before changing the comparison. The completed exercise is a small, inspectable example of data and execution working together.