RealDocs

UKismetMathLibrary::Subtract_ByteByte

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Subtracts byte B from byte A. The default B=1 makes it a convenient decrement node in Blueprints.

Caveats & Gotchas

  • uint8 is unsigned: if B > A the result underflows and wraps to a large value (e.g. 0-1 = 255). There is no runtime error or clamping.
  • For health/ammo systems where going below 0 is invalid, clamp A to B before subtracting or use int32 instead.

Signature

static UE_INL_API uint8 Subtract_ByteByte(uint8 A, uint8 B = 1);

Parameters

Name Type Description Default
A uint8 Minuend.
B uint8 Subtrahend. 1

Return Type

uint8

Example

Decrementing ammo C++
if (Ammo > 0)
{
    Ammo = UKismetMathLibrary::Subtract_ByteByte(Ammo, 1);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.