Hi all!
I am making a helicopter game and I am having inconsistent results depending on the framerate of the game.
Here is my input for the helicopter:
void AHelicopter::Yaw(const FInputActionValue& Value) { // Heli cannot do anything if the engine is not running if (EngineState != EEngineState::Running) return; float YawInput = Value.Get<float>() * (bIsFreelooking ? 0.0f : 1.0f); TargetRotation.Yaw = YawInput * RotationSensitivity; } void AHelicopter::Pitch(const FInputActionValue& Value) { // Heli cannot do anything if the engine is not running if (EngineState != EEngineState::Running) return; float PitchInput = Value.Get<float>() * (bIsFreelooking ? 0.0f : 1.0f); TargetRotation.Pitch = PitchInput * RotationSensitivity; } void AHelicopter::Roll(const FInputActionValue& Value) { // Heli cannot do anything of the engine is not running if (EngineState != EEngineState::Running) return; float RollInput = Value.Get<float>() * (bIsFreelooking ? 0.0f : 1.0f); TargetRotation.Roll = RollInput * RotationSensitivity; } Here is how that input gets used in the Tick() function:
// Update the current rotation to match the target rotation CurrentRotation = UKismetMathLibrary::RInterpTo(CurrentRotation, TargetRotation, DeltaTime, RotationSpeed); const FVector LocalTorque = FVector(-CurrentRotation.Roll, -CurrentRotation.Pitch, CurrentRotation.Yaw); const FVector WorldTorque = UKismetMathLibrary::TransformDirection(GetActorTransform(), LocalTorque); HelicopterMesh->AddTorqueInDegrees(WorldTorque, NAME_None, true); I have noticed if the game runs at 200+ fps, the observed rotation is slow. And by contrast if the game is running at 30 fps the rotation is noticeably faster.
My intuition would say that because I am using this in tick, I should multiply the rotation force by DeltaTime, but that would lower the rotation speed even more as the framerate goes up. I am not sure what is happening and would greatly appreciate any help.
