虚幻引擎4如何根据输入时序轮询/处理输入?

问题描述 投票:0回答:1

对于某些类型的游戏,包括节奏动作游戏,精度要求超过0.0166 ...秒。在这种情况下,对于玩家来说,基于帧的输入处理可能不足。

我对Unity有一定的经验,我知道unity会处理每帧的输入(更新调用),直到最新版本为止。这意味着将对来自播放器的输入以及显示刷新率进行轮询,显示刷新率通常为每秒60帧。

现在,我是UE4的新手,并且想知道它如何处理来自播放器的输入。我看到Tick或Tickcomponent的行为似乎与统一更新类似。 (UE4文档说“该函数在此ActorComponent上调用了每个帧”)UE4是否还按帧处理输入,或者即使渲染帧发生的时间比实际输入时间晚,时间戳也可用于输入吗?

一种情况:输入专门发生在4.052秒,并且任何基于帧的调用发生在4.057秒。

在这种情况下,UE4是否认为输入发生在4.052或4.057?

input unreal-engine4
1个回答
0
投票

它是基于帧的,没有时间戳。您可以自己检查。创建一个新的C ++ Class> Character。在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中,将n放到您的关卡中,单击播放,您将看到每帧的DeltaTime正在发生。如果按空格键(默认情况下调用Jump()),然后立即按ESC键停止游戏,则可以比较2个DeltaTimes。相同!我希望能回答您的问题。

© www.soinside.com 2019 - 2024. All rights reserved.