E0513 UStaticMeshComponent

Hello, I’m just following a UE 4 tutorial from here:


and I’ve simply copied and pasted the code from the tutorial. Yet, there are multiple errors. I’m including the one error message that has plagued me in the past as well (with other projects).

Severity Code Description Project File Line Suppression State
Error (active) E0513 a value of type “UStaticMeshComponent *” cannot be assigned to an entity of type “USceneComponent *” HowTo_PlayerInput e:\UnrealEnginesavedfiles\HowTo_PlayerInput\Source\HowTo_PlayerInput\MyPawn.cpp 20

Any help appreciated.

Here is the cpp file:

// Fill out your copyright notice in the Description page of Project Settings.

#include “MyPawn.h”

// Sets default values
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;

// Set this pawn to be controlled by the lowest-numbered player
AutoPossessPlayer = EAutoReceiveInput::Player0;

// Create a dummy root component we can attach things to.
	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
// Create a camera and a visible object
UCameraComponent* OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("OurCamera"));
OurVisibleComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("OurVisibleComponent"));
// Attach our camera and visible object to our root component. Offset and rotate the camera.
OurCamera->SetRelativeLocation(FVector(-250.0f, 0.0f, 250.0f));
OurCamera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f));


// Called when the game starts or when spawned
void AMyPawn::BeginPlay()


// Called every frame
void AMyPawn::Tick(float DeltaTime)


// Called to bind functionality to input
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)


I had the very same error message from VS. However, the compile went through and build succeeded with no problems. I check the inheritance of these two components - USceneComponent and UStaticMeshComponent, and it turns out UStaticMeshComponent is indeed a subclass of USceneComponent and therefore the assignment should be fine.

It seems VS Intellisense doesn’t parse the headers well and consider these two are not related. Hope this helps!

There are two ways make the error message disappear.

  1. Include below header file from the CPP
  2. Otherwise cast the pointer.

Sometimes happen when Unreal Engine is open while compiling the code with Visual Studio.