Access KismetMathLibrary?

I’m attempting to access a static function in the KismetMathLibrary.

  FVector X,Y,Z;          
  FRotator Rot = UKismetMathLibrary::MakeRotationFromAxes(X,Y,Z);

I’m getting this error

Module.ShooterGame.cpp.obj : error LNK2019: unresolved external symbol "public: static class FRotator __cdecl UKismetMathLibrary::MakeRotationFromAxes(class FVector,class FVector,class FVector)" (?MakeRotationFromAxes@UKismetMathLibrary@@SA?AVFRotator@@VFVector@@00@Z) referenced in function "public: virtual void __cdecl AShooterPlayerController::Test(void)" (?Test@AShooterPlayerController@@UEAAXXZ)
    1>D:\UE4_Project\ShooterGame\Binaries\Win64\RocketEditor-ShooterGame.dll : fatal error LNK1120: 1 unresolved externals

What do I need to do to make this work?

The UKismetMathLibrary does not have its symbols exported. We’ll discuss whether it should or not.

What it is doing, you can do easily yourself

FRotator Rot = FMatrix(X, Y, Z, FVector::ZeroVector).Rotator();

X, Y, Z should be normalized vectors. If you don’t already have normalized vectors you could do X/Y/Z.SafeNormal() there instead.

Marc,

Thanks for a solution! The UKismetMathLibrary appears to have some other useful functions not found anywhere else eg. VSize,FMin. I know users could rewrite most of these functions on there own, but feel it would be more convenient to have access if possible. Many thanks!

The vast majority of what is in KismetMathLibrary (and its intention though it doesn’t 100% live up to it) is just wrappers around existing functionality so that Kismet has a way of doing those operations. To take your two examples:

VSize is simply A.Size()
FMin is simply FMath::Min(A,B)

We are hoping to at some point expose the implementations of these functions so it is easier for programmers to see what these functions do and how they can do the same things from their own code. However, I can’t guarantee it will happen or give you a timeline as to when. In general I would recommend looking at the APIs of the base math classes (vector, matrix, etc.) and FMath as I think you will find in most cases you have access to what you need in C++ through those.

Awesome! That definitely makes more sense. Thanks again.

It works if called from my pawn class.