I have started working in Unreal Engine 4 and opened up the most basic tutorial with c++ on their web site. So this is the code they provided
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);
}
And this is the explanation of what it should do: The code we’ve just written will cause FloatingActors to bob up and down smoothly, using the RunningTime variable we created to keep track of our movement over time.
And when you compile it it does that, but it doesn’t tell me anything about how or why it works. The thing that bugs me is as the title say the movement equation :
DeltaHeight = sin(RunningTime + DeltaTime) - sin(RunningTime)
If anyone could explain this to me it would be greatly appreciated. What I’m asking would be the Mathematical/Physical basis behind this equation.