它是基于帧的,而不是时间戳。
你可以自己检查。
创建一个新的 C++ 类 > 字符。
在该类的 Visual Studio 中找到 Tick() 并像这样更改它:
void NameOfClass::Tick(float DeltaTime)
Super::Tick(DeltaTime);
if (GetWorld() != nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("DeltaTime of Frame: %f"), GetWorld()->TimeSeconds)// Returns time in seconds since world was brought up for play, IS stopped when game pauses, IS dilated/clamped
UE_LOG(LogTemp, Warning, TEXT("DeltaTime of Frame FDateTime ms: %f"), FDateTime::Now().GetMillisecond())// Gets the local date and time on this computer.
}
然后找到其中一个输入函数,例如Jump() 并像这样改变它:
void NameOfClass::Jump()
{
Super::Jump();
if (GetWorld() != nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("DeltaTime of Jump: %f"), GetWorld()->TimeSeconds)// Returns time in seconds since world was brought up for play, IS stopped when game pauses, IS dilated/clamped
UE_LOG(LogTemp, Warning, TEXT("DeltaTime of Jump FDateTime ms: %f"), FDateTime::Now().GetMillisecond())// Gets the local date and time on this computer.
}
}
不要忘记 .cpp 顶部的 UWorld 的#include
#include "Runtime/Engine/Classes/Engine/World.h"
编译。
在 UE4Editor 中将类拖放到您的关卡中,点击播放,您将看到每一帧的 DeltaTime 正在发生。如果您按空格键(默认调用 Jump())并立即 ESC 停止游戏,您可以比较 2 个 DeltaTimes。完全相同的!
我希望这能回答你的问题。