Unresolved external symbol for UKismetMathLibrary::FindLookAtRotation

When I try to use FindLookAtRotation like this

#include "Kismet/KismetMathLibrary.h"

FRotator new_rot = UKismetMathLibrary::FindLookAtRotation(location, this->GetTransform().GetLocation());


1>MyProject3Character.cpp.obj : error LNK2019: unresolved external symbol "public: static class FRotator __cdecl UKismetMathLibrary::FindLookAtRotation(class FVector const &,class FVector const &)" (?FindLookAtRotation@UKismetMathLibrary@@SA?AVFRotator@@AEBVFVector@@0@Z) referenced in function "protected: void __cdecl AMyProject3Character::SelectActorWithMouse(void)" (?SelectActorWithMouse@AMyProject3Character@@IEAAXXZ)
1>E:\UnrealProjects\ThirdPersonProject\Binaries\Win64\UE4Editor-MyProject3.dll : fatal error LNK1120: 1 unresolved external

How would I fix such an error?

The kismet math library isn’t set up to be usable from outside the Engine module, so that’s why you get the linker error. You have two options:

  1. Just call the C++ code directly. In this case that function is a very trivial wrapper so I would just do that.
  2. Locally change KismetMathLibrary to be accessible outside of Engine. You would do this by Adding ENGINE_API to the front of the class definition and removing MinimalAPI. Look at GameplayStatics as an example of how to do this.

So I read this because I was having the same issue and was a little confused as to what code to call. To achieve what you’re looking for it should look like this:

FRotationMatrix::MakeFromX(targetPawn->GetActorLocation() - lookingPawn->GetActorLocation()).Rotator();

thank you… simple and elegant.