The Method of [UE4]GetWorld()->GetDeltaSeconds()

void AAvatar::Yaw(float amount)
{
    if (Controller && amount)
    {
        // AddControllerYawInput()function is used to change the controller's Yaw variable, i.e. to increase the amount of vertical axis rotation.
        // The GetWorld() function gets the world pointer UWorld*, and calls GetDeltaSeconds() from the world pointer to get the time spent per frame.
        // The reason for multiplying the elapsed time per frame is to make each [second] increase the amount of change by 200.0f * amount.
        // If you don't multiply the time spent per frame, then each [frame] will increase the amount of change by 200.0f * amount. (Note that the number of frames per second is not necessarily fixed because the amount of rendering per second varies.)
        // By controlling the variables by the number of frames, then the game looks less smooth. Imagine that the game character moves quickly when the machine is good, and slowly when the machine is bad, is this fair to the player?
        AddControllerYawInput(200.f * amount * GetWorld()->GetDeltaSeconds());
    }
}

Similar Posts: