RealDocs

FMath::Sin

function Core Since 4.0
#include "GenericPlatform/GenericPlatformMath.h"
Access: public Specifiers: static

Description

Returns the sine of an angle given in radians. A double overload exists for higher precision. Returns values in the range [-1, 1].

Signature

static UE_FORCEINLINE_HINT float Sin(float Value)

Parameters

Name Type Description Default
Value float Angle in radians.

Return Type

float

Caveats & Gotchas

  • Input is in radians, not degrees. Convert with FMath::DegreesToRadians(Degrees) before calling.
  • For animation and oscillation patterns, consider FMath::Sin combined with a time accumulator. Be aware that float precision degrades as the accumulator grows large — periodically wrap or reset it.
  • When you need both sine and cosine of the same angle (e.g. building a 2D direction vector), use FMath::SinCos(&S, &C, Angle) — one call instead of two, measurably faster in tight loops.

Example

Oscillate actor height using a sine wave C++
// In Tick — bob up and down smoothly
AccumulatedTime += DeltaTime;
float BobOffset = FMath::Sin(AccumulatedTime * BobFrequency) * BobAmplitude;
SetActorLocation(BaseLocation + FVector(0.f, 0.f, BobOffset));

Tags

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.