UKismetMathLibrary::Conv_BoolToByte
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPureBlueprintAutocast
Description
Converts a boolean to a byte (uint8): false returns 0, true returns 1.
Caveats & Gotchas
- • Returns only 0 or 1 — never any other byte value. If you need a full range mapping from bool to a custom byte enum value, use a Select node or ternary expression instead.
- • Storing bools as bytes in replicated structs can save bandwidth when a UPROPERTY bitfield isn't available, but be aware that Blueprint byte pins display as enum selectors when bound to a UENUM, which can cause unexpected display issues if the byte is later used as an enum.
Signature
static UE_INL_API uint8 Conv_BoolToByte(bool InBool) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InBool | bool | The boolean value to convert. | — |
Return Type
uint8 Example
Pack a bool into a byte for custom binary serialisation C++
bool bFeatureEnabled = IsFeatureEnabled();
uint8 PackedByte = UKismetMathLibrary::Conv_BoolToByte(bFeatureEnabled);
BitStream.WriteByte(PackedByte); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?