02 - Properties & types
Shows the friendly types TPScript maps to C++, plus field private for implementation detail.
Full source
include "CoreMinimal.h"
include "GameFramework/Actor.h"
uclass AExampleProps : AActor meta: api=EXAMPLES_API
{
method public virtual void BeginPlay() override {
Super::BeginPlay();
PrimaryActorTick.bCanEverTick = true;
}
prop public float Damage EditAnywhere BlueprintReadWrite category="Example" default=10.0f
prop public FName WeaponTag EditAnywhere BlueprintReadWrite category="Example" default="Rifle"
prop public FText DisplayText EditAnywhere BlueprintReadWrite category="Example" default=NSLOCTEXT("", "DisplayText", "Hello")
prop public bool bEnabled EditAnywhere BlueprintReadWrite category="Example" default=true
prop public int32 MaxCount EditAnywhere BlueprintReadWrite category="Example" default=5
field private float FrameCounter
method public virtual void Tick(float DeltaTime) override {
Super::Tick(DeltaTime);
FrameCounter += 1.0f;
if (FrameCounter > 100.0f && bEnabled)
{
UE_LOG(LogTemp, Warning, TEXT("reached 100 frames, weapon: %s"), *WeaponTag.ToString());
FrameCounter = 0.0f;
}
}
}
Line by line
prop public float Damage ... default=10.0f- afloat.prop public FName WeaponTag ... default="Rifle"- anFName(fast, hashed label).prop public FText DisplayText ... default=NSLOCTEXT(...)- anFText(localized text).prop public bool bEnabled ... default=true- a boolean.prop public int32 MaxCount ... default=5- anint32.field private float FrameCounter- a private plain field (noUPROPERTY, invisible to the editor and Blueprints). TPScript knowsframehere is a float; the explicitfloatkeeps it unambiguous.
What the friendly types map to
| TPScript | C++ |
|---|---|
float | float |
FName | FName |
FText | FText |
bool | bool |
int32 | int32 |
You could also write the friendly forms (number, name, text, count) on a high-level class and get the same C++ types. See Type system.
Behavior
FrameCounter accumulates every tick; once it passes 100 (and bEnabled is true), it logs the current weapon tag and resets. bEnabled gates the whole check - flip it to false in Blueprint and the log stops.
Next: 03 - Functions & Events.