Shooter Game's Player's Camera?

Hi,

I’m new to UE4 but in the shooter game example i noticed that in the BP Pawn, there is no camera component. Then filled with curiosity I went through the cpp and the header file still there was no sing of a camera component at all. So, I came to this question: Where does the character see from in the game? Since there is no camera component I figured that there must be an alternative. Anyone know what it is?

Thanks in advance,

2 Likes

Hey there, i dont have that project but what you could do is play the game and eject possesion and select the character and see the component list to see if you can find the camera.

1 Like

Thank You for the reply, but its not there. Most likely its hard attached to the FPP Pawn in the camera manager, but its hard to make out with Epic’s slightly messy code.

Maybe it’s on the player controller.

To add to this, the doc is pretty clear but on the surface can seem obscure.

If you haven’t seen this Shooter Game | Unreal Engine Documentation it details what you want to know.

You’ll see this line “AShooterCamera::UpdateCamera() is executed each tick.”

It is actually “ShooterPlayerCameraManager.cpp” that has the UpdateCamera() method.

Inside there every tick they are “hard” setting the Mesh1P to follow the cameras pitch/yaw.
I recently had to go in there to fix a bug with the Mesh1P and Camera whenever crouch is enabled.

If you continue to follow the code from there you can see this line “MyPawn->OnCameraUpdate(GetCameraLocation(), GetCameraRotation());”

Which takes you to the “ShooterCharacter.cpp” and its “OnCameraUpdate()” method. Inside there “DefMesh1P” is the Mesh1P mesh and you can see exactly how the “Hard-attaching” is happening.

Hopefully this gives more info. Essentially what I think they mean by “hard-attached” is setting the position every tick through code in the UpdateCamera().

1 Like

I’m running into a problem where the Mesh1P doesn’t move vertically correctly to match the player’s crouch height. I’m wondering if this was a similar problem that you were running into that you mentioned in your post? If so, how did you go about solving it?

So, if someone like me is also searching for the decision of the problem, here is how I done this:

FVector DefMeshLocation = DefMesh1P->RelativeLocation; if (bIsCrouched) { const float CrouchedHeightAdjust = DefaultBaseEyeHeight - BaseEyeHeight; DefMeshLocation -= FVector(0.f, 0.f, CrouchedHeightAdjust); } const FMatrix DefMeshLS = FRotationTranslationMatrix(DefMesh1P->RelativeRotation, DefMeshLocation);

Where DefaultBaseEyeHeight is a value of the BaseEyeHeight at begin play.

1 Like