To make a âtrueâ first person camera you need to make a c++ child class of LyraCameraMode. I called mine LyraCameraMode_FirstPerson to keep with the naming they had established for third person and top down. I also chose to create it in the ShooterCore game feature similar to what was done with the Top Down Arena camera mode in that game feature plugin. In the new child class, you need to override GetPivotLocation() and in the overridden function you need to get and return the head bone location. I took some code from the ThirdPerson c++ class and modified it as a test.
In my LyraCameraMode_FirstPerson .h
protected:
virtual FVector GetPivotLocation() const override;
In my LyraCameraMode_FirstPerson .cpp
FVector ULyraCameraMode_FirstPerson::GetPivotLocation() const
{
const AActor* TargetActor = GetTargetActor();
check(TargetActor);
if (const APawn* TargetPawn = Cast<APawn>(TargetActor))
{
// Get mesh socket location for head bone
if (const ACharacter* TargetCharacter = Cast<ACharacter>(TargetPawn))
{
return TargetCharacter->GetMesh()->GetSocketLocation("head");
}
return TargetPawn->GetPawnViewLocation();
}
return TargetActor->GetActorLocation();
}
Make sure you also add 2 includes into your .cpp file:
#include âGameFramework/Pawn.hâ
#include âGameFramework/Character.hâ
After you have compiled and can see your class in blueprints, you can then create a child blueprint (I called mine CM_FirstPerson).
Next, open the HeroData_ShooterGame file and change the Camera-> Default Camera Mode to the new CM_FirstPerson.
Press play and youâll have a first person camera attached to the head bone of the skeleton.
To adjust the aim down sights, youâll need to create another child blueprint of the LyraCameraMode (I called mine CM_FirstPersonADS) and adjust the FOV to something slightly smaller for mild zoom effect.
Then you will need to edit the GA_ADS blueprint in ShooterCore Content->Input>Abilities and have the ADS ability call the CM_FirstPersonADS file you just created. Compile, save and play.
There is additional work needed if you want to use offsets, curves, etc., this is just the most basic setup to get a âtrueâ FPS camera that I was playing around with.
Major props to LFA on YouTube for the inspiration I got after watching their video on first person for Lyra.