https://docs.unrealengine.com/latest/INT/Programming/Tutorials/PlayerInput/1/index.html
I’m following this tutorial here trying to understand why my input isn’t being recognized and I’m getting \MyPawn.cpp(22) : error C2039: 'SetupAttachment': is not a member of 'UCameraComponent'
and \MyPawn.cpp(25) : error C2039: 'SetupAttachment': is not a member of 'USceneComponent'
errors when following the tutorial. Am I doing something wrong or is this because I’m following a 4.9 tutorial in 4.11? I’m following the syntax of the code in the tutorial verbatim.
// MyPawn.h
#pragma once
#include "GameFramework/Pawn.h"
#include "MyPawn.generated.h"
UCLASS()
class INPUTTEST_API AMyPawn : public APawn{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
USceneComponent* OurVisibleComponent;
public:
// Sets default values for this pawn's properties
AMyPawn();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
};
// MyPawn.cpp
#include "InputTest.h"
#include "MyPawn.h"
// Sets default values
AMyPawn::AMyPawn(){
// 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->SetupAttachment(RootComponent);
OurCamera->SetRelativeLocation(FVector(-250.0f, 0.0f, 250.0f));
OurCamera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f));
OurVisibleComponent->SetupAttachment(RootComponent);
}
// Called when the game starts or when spawned
void AMyPawn::BeginPlay(){
Super::BeginPlay();
}
// Called every frame
void AMyPawn::Tick( float DeltaTime ){
Super::Tick( DeltaTime );
}
// Called to bind functionality to input
void AMyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent){
Super::SetupPlayerInputComponent(InputComponent);
}