I have a security camera model that must look at the player. This camera mesh has two connected bones, one at the root, and one along the direction the lens is facing.
I simply want to rotate the lens bone to look at the player pawn. So I added a SkelControlSingleBone to the animtree as shown in this screenshot . My simple code is as follows:
//Gets called every tick to update the camera rotation to look at the player pawn
simulated function RotateCamManually()
local Rotator DirToPawn;
SkelMeshComp.GetSocketWorldLocationAndRotation('CameraSocket', CameraBoneLocation, , );
DirToPawn=Rotator(PWNPawn(PWNPlayerController(GetALocalPlayerController()).Pawn).Location - CameraBoneLocation);
SkelMeshComp is the skeletal mesh,
CameraBoneLocation is the world location of a socket on the Camera lens bone,
and ASkelControl is the skeletal controller
The bone rotates fine, but I cannot get it to look directly at the player. It is always perpendicular (looking towards the right) of the player.
I've tried so many things but cannot seem to get it right. Any help would be much appreciated as usual.