Cross product produces incorrect values...?

I’m bit confused. I tried to create the right vector by cross product of the forward vector of the component and the normal vector of the ground. But when I do the cross product, I get the left vector. This is my code.

DrawDebugDirectionalArrow(GetWorld(), TraceResult.ImpactPoint, TraceResult.ImpactPoint + FVector::CrossProduct(GetForwardVector(), TraceResult.ImpactNormal) * 100, 50, FColor::Red, false, DeltaTime, 0, 5);
DrawDebugDirectionalArrow(GetWorld(), TraceResult.ImpactPoint, TraceResult.ImpactPoint + GetForwardVector() * 100, 50, FColor::Blue, false, DeltaTime, 0, 5);
DrawDebugDirectionalArrow(GetWorld(), TraceResult.ImpactPoint, TraceResult.ImpactPoint + TraceResult.ImpactNormal * 100, 50, FColor::Green, false, DeltaTime, 0, 5);

And this is the result.


What am I missing?

1 Like

Unreal is a left-handed coordinate system so “forward x up => left” is correct. If you want the right you either have to negate it or reverse your cross product.

3 Likes