How to make lyra starter game first person?

hello i am trying to turn the lyra sample game a first person shooter but I have an issue where the camera seems to move behind the character when you look down

i replaced the mannequin with a metahuman (it messed up the gun holding but oh well) then i hid the face when player controlled and changed the x&y camera offset curves to 0, which kinda works (you have to look down and then up again for some reason tho):


however when you continue to look down it looks like this:

i dont understand why its doing this, i set up a print string on tick for the camera position, and it changes when you just move the mouse, not just rotates. i looked in camera and input blueprints and c++ classes for where the camera position would change but didnt find anything. i thought maybe it was the camera penetration prevention system but disabling that didnt help

any other ideas??

5 Likes

Ive been wanting to do the same thing. Did you get this working?

I am progressing on this. I customized the Cosmetic system with a perspective based version where the controller only adds the Subjective cosmetics (Third person) on the server and the remote clients ( And the owning client if in third person ).

Then there is an ObjectiveProxyCosmeticsComponent that lives on the owning client pawn that manage the objective perspective cosmetics (First Person) with their own list of Child Actor Components.

To setup those to use the related character parts for each perspective, i did it through what i called a PerspectiveCharacterPartCosmeticSet that will declare two related Character Part to apply on both perspective.

Its still in the work so if there is someone interested in this i can give you some updates as i work on it.

1 Like

3 Days pass :stuck_out_tongue: Curious on anyone’s progress on this

I mean, it probably comes down to fundamentally changing how the camera setup is TBH (cause control rotation be weird with this setup currenlty). There are different approaches to make a FPS cam: Have 1st and 3rd person mesh approach, or the TrueFPS route which the camera prolly needs to be attached to the head bone and adjustments that way too.

At the end of the day, A lotta people want to mod it to do different game types (ARPG, FPS, etc.) … but it seems it’s a bit in discovery mode to understand how to approach different funamentals with doing so. It’s a top down approach to visualizing it (starting with each LyraExperienceDefinition and seeing all of the asset stuff from there). Would love to see a more… comprehensive breakdown on the Setup and engineering side more :confused: . But, for starters, I guess one coulllddd make a child of LyraCameraMode to see if they can adjust it to make that work accordingly for the FPS camera

One thing to note is that the way the animation blueprint works is much different than I’m used to (in UE4). There’s a “linked-layer” mechanic that allows the animations to be injected via other blueprints associated with the character (in this case, the weapons happen to contain the character animations). This proved to be a problem because I tried “hiding the mesh from the owner” and doing a split-body style approach (like the original ShooterGame), but I ended up with a permanent T-Pose.

1 Like

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.

18 Likes

Hi Kromtak,

Thanks for the details it works! Im trying to set up the ADS similar to most first person shooters i think they do it by fixing the camera to a weapon socket. Do you have any ideas around this. Thanks

Hi can you post the code how you have got it layed out for both .h and .cpp files for the First-person. Mine keeps crashing. Thanks

Thanks for the speedy reply i have been on it all day i will give that ago. In regards to making the child of ‘LyracameraMode’ did you do this from inside unreal engine then move to visal or copy the files in visal code.

1 Like

Thanks. It strange i still get the crash when i enter a game

My game also crashes when i try to do this, could anyone send me their uproject, it could be some setting thats different or something idk

I have a weird thing going on with the shotgun weapon using this approach to a FP camera in c++, it only shows one impact decal, like the rifle does, but when shooting the bots they are affected by multiple shots.

I added a little to the .h and .cpp allowing you to change what you want that camera attached to, pretty simple but just wanted to share.
At line 33 in the .h I added

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "First Person")
		FName CameraAttachSocket = "head";

and in the .cpp I changed line 100 to use that FName, not sure is thats the correct way to do it but it works fine.

return TargetCharacter->GetMesh()->GetSocketLocation(CameraAttachSocket);
3 Likes

This works perfectly but the character is in T-POSE, if i exit editor (SHIFT + F1) and detatch from player, then move the camera out till i see my character then the idle pose animation starts. I then go back playing and possessing the actor (Character) and everything works.

How can i solve the T-POSE error? i digged deep into the anim blueprint and blendables but can’t figure it out…

1 Like

same thing here … i can look down in first person view and it disables tpose. or i can press f8 and go outside of body and then back in and im out of t pose… if i look straight all i see is crosshair and my bullet tracers while shooting.

if you want a quick fix and your tpose is stopped by looking down… then just add controller pitch input in blueprint using a sequence or something in the B_Hero_ShooterGame pawn’s event graph.

I’ve found this youtube series on Lyra, that enables true first person, including a FPS mesh (visible to player), while the 3rd person mesh stays visible for other players… Also, it has procedural aim down sight…

Though, beware… I’m able to get it working in UE5.1, until the Animation BP… Still figuring out how to deal with it… The Anim Linked Layers, ain’t working flawless for me… But it should work perfectly in UE 5.0.x

1 Like

Thank you for you help! I was looking a solution to the same problem

Hello people, I am getting a strange line in the upper left/right areas for FPS when overriding the GetPivotLocation() as stated above. Do you have any hints on how to proceed and debug this?

Thanks