对于某些类型的游戏,包括节奏动作游戏,精确度比0.0166...second更高。在这种情况下,基于帧的输入处理对于玩家来说可能是不够的。
我对Unity有一点经验,我知道unity在最近的版本之前每帧都会处理输入(更新调用)。这意味着来自播放器的输入将与显示的刷新率一起轮询,刷新率通常为每秒60帧。
现在我刚接触UE4,想知道它是如何处理来自播放器的输入的。我看到Tick,或者Tickcomponent,它的行为看起来和Update很相似。(UE4文档写道:“在这个ActorComponent上调用每一帧的函数) UE4是否也处理每一帧的输入,或者即使渲染帧发生得比实际输入时间稍晚,时间戳也可以用于输入吗?”
一个场景:输入发生在4.052秒,任何基于帧的调用发生在4.057秒。
在这种情况下,UE4是否会像在4.052或4.057中那样感知输入?
发布于 2020-04-28 22:24:32
它是基于帧的,而不是时间戳的。你可以自己检查一下。创建一个新的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中拖放你的关卡中的类,点击play,你会看到每一帧的DeltaTime正在发生。如果您按空格键(默认情况下调用Jump())并立即按ESC停止游戏,您可以比较2个DeltaTimes。一模一样!我希望这回答了你的问题。
https://stackoverflow.com/questions/61473746
复制相似问题