#fmath
For vehicle physics in Unreal Engine, should use always atan2 instead of atan? #UnrealEngine #Programming #Gamedev

This:
mSlipAngle = FMath::Atan2(mLocalVelocity.Y, absForwardVelocity)

Instead of:
mSlipAngle = FMath::Atan(mLocalVelocity.Y / (absForwardVelocity + FGearUtility::epsilon));
October 31, 2025 at 7:37 PM
The Start of Something New?
I'm excited to launch this account dedicated to teaching Cambridge AS & A Level Mathematics (9709) and Further Mathematics (9231) for the 2026-2027 exams!

#manim #math #alevels #alevel #fmath #furthermath #furthermaths #mathematic #cambridge #trending
October 1, 2025 at 1:26 PM
today in Unreal Has A Node For That Already: mirror vector by normal

(and in c++, it's FMath::GetReflectionVector)
October 1, 2025 at 3:16 AM
I have narrowed it down to some form of math/boolean evaluation problem. Here is a minimal reproduction on Win64 Development Editor configuration:

Comparison A resolves to True
Comparison B resolves to False
They should both fail!
September 7, 2025 at 12:02 AM
yes!!! I should have known fMath would be the one to get the reference!! You just made my evening
August 22, 2025 at 5:13 AM
Ran into this again last night on UE 4.27 so I guess it's extra broken lol. I received another VS update after that and an OS update so who knows how screwed up my toolchains are now. My fix was to make a custom NAN macro that maps to ((float)FMath::Sqrt(-1)) and use it for all compilers/versions.
Wheeeew an update to VS 2017 broke the C Runtime's NAN macro on old versions of UE4. That was weird... FMath::Sqrt(-1) to the rescue I guess?
July 9, 2025 at 9:32 PM
Wheeeew an update to VS 2017 broke the C Runtime's NAN macro on old versions of UE4. That was weird... FMath::Sqrt(-1) to the rescue I guess?
July 8, 2025 at 3:45 AM
Best way to detect if a value increases or decreases?

What i have now:
-
bool isLngFrictionUp = (mLngFriction - aLastLngF) > 0.001f;
aLastLngF = FMath::Lerp(aLastLngF, mLngFriction, 0.1f);
float lerpLngF = isLngFrictionUp ? 1.0f : 2.0f;
-
What you think? Any optimization/correction?
June 20, 2025 at 4:06 PM
🔍 Floats are liars!
Comparing floats in Unreal? Be careful — Value == 1.f might fail due to IEEE-754 imprecision.

✅ Use FMath::IsNearlyEqual() or IsNearlyZero()
🎨 In Blueprints? Use the “Nearly Equal” node.

#UnrealEngine #GameDev #CPP
May 19, 2025 at 12:48 AM
Never compare floats directly.
Use the function that your engine gave you, or use an epsilon (nerd name for "a kinda small number).

Unity: Mathf.Approximately(a, b)

Unreal: FMath::IsNearlyEqual(a, b)

With an epsilon: abs(a - b) < 0.0001
April 18, 2025 at 6:56 PM
Of course, similar problem trying to create a basic expression evaluator node e.g. with FMath::Eval.

It feels like this comment is pointing to some nontrivial missing steps. E.g. for expr node, dealing with an AST would probably be worse? To the extent that the proof of concept doesn't mean much.
February 24, 2025 at 7:30 PM
More code Shenanigans 😆

The refactored version works, formula clamps to 0-1 but gives slighty different results, but cant find the problem.

frontShare = FMath::Max(0.0f, FMath::Min(1.0f, mTorqueShares[0] -lockRatio *(1.0f -(rearSpeed /frontSpeed )) *mTorqueShares[0]));

Any idea? #UE5 #Programming
February 2, 2025 at 2:00 PM
Any better way to get the same?
bool isAccel = (mAccel - aOldAccel) > 0.01f;
aOldAccel = FMath::Lerp(aOldAccel, mAccel, 0.2f);
debug = isAccel ? 222.0f : 0.0f;

If Throttle goes up = 222.0, if stays/down = 0.0f
Added "0.01f;" as tolerance in bool or not works.
#UnrealEngine #Gamedev #Indiedev
November 21, 2024 at 12:17 PM
If you're using the #UnrealEngine plugin Motion made by Kia Armani and you want to add some inertia to the camera rotation, you could do it like this: https://gist.github.com/Plimsky/925aacdcad0e9d259f690efe562d7bdf

#UE5 #gamedev #indiedev #code #cpp
November 14, 2024 at 3:46 PM
Ok, so optimized to: x*abs(x) , this:
mTargetSteeringInput * FMath::Abs(mTargetSteeringInput)

Guess is the best way now? If anything better, let me know.

Credits to @xblasco.bsky.social
I need to use: FMath::Pow(mTargetSteeringInput, 2) but then result is always positive. This works:

FMath::Pow(mTargetSteeringInput, 2) * FMath::Sign(mTargetSteeringInput)

But, Is the correct way? Better alternatives?
#UnrealEngine #UE5 #Gamedev #Indiedev
November 1, 2024 at 2:05 PM
FMath::Abs()
November 1, 2024 at 2:04 PM
I dunno how UE code works but multiplying a number by its absolute value is what you're looking for I think, since the pow function is slow in comparison, and the absolute value function is like. O(1) or something.

my assumption for UE is:
mTargetSteeringInput * FMath::Abs(mTargetSteeringInput)
November 1, 2024 at 1:54 PM
I need to use: FMath::Pow(mTargetSteeringInput, 2) but then result is always positive. This works:

FMath::Pow(mTargetSteeringInput, 2) * FMath::Sign(mTargetSteeringInput)

But, Is the correct way? Better alternatives?
#UnrealEngine #UE5 #Gamedev #Indiedev
November 1, 2024 at 1:40 PM
My favorite way to control #UnrealEngine Timelines is with a custom function SetDuration. Which scales the PlayRate to match a given Duration.
This will make any Timeline of *any Length* play for the given Duration.
I prefer to then author my curves from 0-1.

#GameDev
github.com/BenVlodgi/UE...
February 8, 2024 at 5:14 PM