UKismetMathLibrary::Vector4_MirrorByVector3
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticBlueprintPure
Description
Reflects a direction vector across a surface normal using only the XYZ components, equivalent to D - 2*(D·N)*N. Models specular reflection or a ray bouncing off a mirror surface.
Caveats & Gotchas
- • SurfaceNormal should be normalized; passing a non-unit normal scales the reflected vector and produces an incorrect result without any warning.
- • W is ignored for the computation but the returned vector's W component is taken from the input Direction's W — if your pipeline expects W=0 for directions, pass Direction with W=0.
Signature
static UE_INL_API FVector4 Vector4_MirrorByVector3(const FVector4& Direction, const FVector4& SurfaceNormal); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Direction | const FVector4& | The incoming direction vector to reflect. | — |
| SurfaceNormal | const FVector4& | The surface normal to reflect across. Should be unit length for correct results. | — |
Return Type
FVector4 Example
Reflect a projectile direction off a surface C++
FVector4 Velocity(1.0, 0.0, -1.0, 0.0);
FVector4 Normal(0.0, 0.0, 1.0, 0.0); // floor
FVector4 Reflected = UKismetMathLibrary::Vector4_MirrorByVector3(Velocity, Normal);
// Reflected == (1, 0, 1, 0) See Also
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?