首先.h代码
UPROPERTY(EditAnywhere)
int CoolDownTime = 1;
int LastTime = 0;
其次,.cpp代码
void ACCC::TestFunc()
{
int NowTime = FPlatformTime::Seconds();
if (!(FPlatformTime::Seconds() - LastTime) > CoolDownTime) {return;}
GEngine->AddOnScreenDebugMessage(-1, 20.0F, FColor::Red, TEXT("HelloWorld"));
LastTime = FPlatformTime::Seconds();
}