UE4_c++简单的延时

这里写图片描述

首先.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();
}

猜你喜欢

转载自blog.csdn.net/qq_36409711/article/details/79190464