UCameraComponent is Undefined

I’m learning UE through this tutorial: https://docs.unrealengine.com/en-US/Programming/Tutorials/PlayerInput/1

There is a line of code from the first part that Visual Studio is not recognizing:

UCameraComponent* OurCamera =
CreateDefaultSubobject(TEXT(“OurCamera”));

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	E0020	identifier "UCameraComponent" is undefined	HowTo_PlayerInput	 C:/pathto/MyPawn.cpp,	18
  1. I think that im missing a include statement for “UCameraComponent” but I have no idea what file i would need to include.
  2. If i am correct does this mean i should expect some of the tutorials to be completely outdated or just missing some small changes?
  3. Is there documentation I could search for UE’s classes and what files they are located in?

You should look API reference just search class name in doc search or google (add “UE4” if it does not pop up)

In below you have the info:

-In which module class is located, you need to add module to dependencies in *.build.cs of your module if you gonna use the class, or else you will get linker errors

-Header file, UBT automatically configure include paths, so only part of path you need to include is after either “Classes” or “Public” directory. So i case of UCameraComponent is this bolded part:

Runtime/Engine/Classes/Camera/CameraComponent.h

2 Likes

I just haven’t been clicking the “c++ api” filter facepalm:

The tutorial forgot to include

#include “Camera/CameraComponent.h”

In MyPawn.cpp

I caught this watching

4 Likes

Still an issue into 2023, thanks for this catch! Just saved me a headache.

1 Like

include “Classes/Camera/CameraComponent.h” this is wrong.
include “Camera/CameraComponent.h” this is correct.