First Person Shooter Tutorial

Hi , i’am having a trouble in changing the camera view , when i write class before the UCameraComponent in FPSCharacter.h it gets created but in the FPSCharacter.cpp it shows an error of cannot set pointer to an incomplete class , i tried to remove the class keyword next to UCameraComponent but it did get worst and it have shown me more errors , any help ??

Hey S2002mounir! I’m sorry to hear this is giving you trouble. We’re in the process of updating that tutorial, and we hope to publish these changes soon. That said, let me see if I can help.

This is near the end of section 2 right ? Looking at my notes, I don’t have any camera components defined as classes in my FPSCharacter.h file. To me it just has:

// FPS camera
UPROPERTY(VisibleAnywhere)
UCameraComponent* FPSCameraComponent;

and includes the header file “#include “Camera/CameraComponent.h”” at the top. In FPSCharacter.cpp, these are the sections I have to attach and reposition the camera:

// Attach the camera component to our capsule component.
FPSCameraComponent->SetupAttachment(CastChecked<USceneComponent, UCapsuleComponent>(GetCapsuleComponent()));

// Position the camera slightly above the eyes.
FPSCameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f + BaseEyeHeight));

I hope that helps. Like I was saying, we’re working on updating this tutorial and I hope we can publish these improvements soon.

Iam facing another problem unfortunatly , in the FPSCameraComponent->SetAttachment(GetCapsuleComponent());

It shows me an error of "Cannot convert argument 1 from ‘UCapsuleComponent’ to ‘USceneComponent’ " and “'UCapsuleComponent* is incompatible with parameter of type ‘USceneComponent’”

Btw i’am totaly new to Unreal so i couldn’t know what’s the problem exactly

Nvm , i found out i had just to include “Components/CapsuleComponent.h”

2 Likes