Uint8 Confusion .. Why not bool?

All booleans in Unreal are prefixed with b. If you see a uint with the b prefix it is declared as a bit field like uint8 bCanBeDamaged:1 The 1 in the end indicates that it only uses 1 bit. bCanBeDamaged == true is perfectly fine to do even though it is a uint8. The reason a bit field is used instead of a bool is to save memory and the only difference between a uint8 bit field and a bool is the way it is declared.



I mostly program in the Unity Engine and usually if I want to find something for example whether a game object (actor in Unreal) can be damaged. In Unity this value would be a really simple boolean and I could check to see if it’s true or false, however in Unreal Engine the bCanBeDamaged value is set up in the Actor.h file as a Uint8 and I cannot find any documentation that I can make sense of that shows how to use these values.

Why is this value and other values set to Uint8 instead of boolean? How do I use Uint8 for example to check whether an actor can be damaged? In Unity it would simply be actorname.bCanBeDamaged == true or !actorname.bCanBeDamaged. How do I do the same thing with a Uint8?

Any insight would be appreciated :slight_smile:

Thank you, very clear explanation.