RealDocs

FMath

struct Core Since unknown
Inherits: FPlatformMath
#include "Math/UnrealMathUtility.h"

Description

The primary math utility struct in Unreal Engine, providing static functions for arithmetic, interpolation, trigonometry, random number generation, and geometric operations. Inherits platform-specific implementations from FPlatformMath via FGenericPlatformMath.

Caveats & Gotchas

  • Many functions have both float and double overloads. When mixing float/double arguments, UE will promote to the higher-precision type via MIX_FLOATS macros — but implicit promotion can silently increase cost in hot paths.
  • Trigonometric functions (Sin, Cos, Atan2) take angles in radians. FRotator stores degrees. Use FMath::DegreesToRadians / FMath::RadiansToDegrees to convert.
  • FMath::RandRange seeded by FMath::RandInit — the global seed is shared across the process. For deterministic random sequences, use FRandomStream instead.

Example

Common usage in a tick function C++
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	// Smoothly interpolate a float toward a target
	CurrentSpeed = FMath::FInterpTo(CurrentSpeed, TargetSpeed, DeltaTime, 5.0f);

	// Clamp health to valid range
	Health = FMath::Clamp(Health, 0.0f, MaxHealth);

	// Random chance per tick (roughly once per second at 60fps)
	if (FMath::RandRange(0, 59) == 0)
	{
		TriggerRandomEvent();
	}
}

Functions (40)

Utility
7
Access Type Name
public function FMath::ApplyScaleToFloat
public function FMath::Eval
public function FMath: MIX_FLOATS_2_ARGS
public function FMath: MIX_FLOATS_3_ARGS
public function FMath: RESOLVE_FLOAT_AMBIGUITY_3_ARGS
public function FMath::SetBoolInBitField
public function FMath: UE_REQUIRES
Geometry
11
Access Type Name
public function FMath::CartesianToPolar
public function FMath::PointDistToLine
public function FMath::PolarToCartesian
public function FMath::SegmentDistToSegment
public function FMath::SegmentDistToSegmentSafe
public function FMath::SegmentIntersection2D
public function FMath::SegmentPlaneIntersection
public function FMath::GetDotDistance
public function FMath::LineExtentBoxIntersection
public function FMath::SegmentTriangleIntersection
public function FMath::SphereDistToLine
Math
14
Access Type Name
public function FMath::Abs
public function FMath::Cos
public function FMath::Sin
public function FMath::Atan2
public function FMath::Clamp
public function FMath::FInterpTo
public function FMath::GetMappedRangeValueClamped
public function FMath::IsNearlyEqual
public function FMath::IsNearlyZero
public function FMath::Lerp
public function FMath::RandRange
public function FMath::Sqrt
public function FMath::Square
public function FMath::VInterpTo
Smoothing
4
Access Type Name
public function FMath::ExponentialSmoothingApprox
public function FMath::CriticallyDampedSmoothing
public function FMath::SpringDamper
public function FMath::SpringDamperSmoothing
Trigonometry
4
Access Type Name
public function FMath::DegreesToRadians
public function FMath::RadiansToDegrees
public function FMath::SinCos
public function FMath::WindRelativeAnglesDegrees

Tags

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.