【发布时间】:2017-04-17 20:29:13
【问题描述】:
我已经开始使用 Unreal Engine 4 并在他们的网站上打开了 C++ 的最基本教程。所以这是他们提供的代码
void AFloatingActor::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
FVector NewLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 20.0f; //Scale our height by a factor of 20
RunningTime += DeltaTime;
SetActorLocation(NewLocation);
}
这是它应该做什么的解释: 我们刚刚编写的代码将使用我们创建的 RunningTime 变量来跟踪我们随时间的移动,从而使 FloatingActor 平滑地上下摆动。
当你编译它时,它会这样做,但它并没有告诉我任何关于它如何或为什么工作的信息。让我烦恼的是,正如标题所说的运动方程:
DeltaHeight = sin(RunningTime + DeltaTime) - sin(RunningTime)
如果有人可以向我解释这一点,将不胜感激。我要问的是这个方程背后的数学/物理解释,或者这个方程来自哪里的解释。为什么会这样。
【问题讨论】:
标签: c++ math physics equation unreal-engine4