大佬帮看看什么问题,菜鸟一个,照着官方文档做,报错了

[复制链接]
查看4268 | 回复5 | 2017-6-9 21:18:01 | 显示全部楼层 |阅读模式
版本4.16
刚接触
照着官方文档入门,报错了。
https://docs.unrealengine.com/la ... rInput/1/index.html


MyPawn.cpp里面,UCameraComponent 和 OurCamera 和 CreateDefaultSubobject 都是未定义标识符,




我的两个文件是这样的
MyPawn.cpp
// Fill out your copyright notice in the Description page of Project Settings.


#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;
        // 将此pawn设置为由最低数量的玩家进行控制
        AutoPossessPlayer = EAutoReceiveInput:layer0;
        // 创建一个可供添加对象的空根组件。
        RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
        // 创建相机和可见项目
        UCameraComponent* OurCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("OurCamera"));  《--就是这里
        OurVisibleComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("OurVisibleComponent"));
        // 附加相机和可见对象到根组件。 偏移并旋转相机。
        OurCamera->AttachTo(RootComponent);
        OurCamera->SetRelativeLocation(FVector(-250.0f, 0.0f, 250.0f));
        OurCamera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f));
        OurVisibleComponent->AttachTo(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(UInputComponent* PlayerInputComponent)
{
        Super::SetupPlayerInputComponent(PlayerInputComponent);


}


还有
MyPawn.h
// Fill out your copyright notice in the Description page of Project Settings.


#pragma once


#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "MyPawn.generated.h"


UCLASS()
class W_API AMyPawn : public APawn
{
        GENERATED_BODY()


public:
        // Sets default values for this pawn's properties
        AMyPawn();


protected:
        // Called when the game starts or when spawned
        virtual void BeginPlay() override;


public:       
        // Called every frame
        virtual void Tick(float DeltaTime) override;


        // Called to bind functionality to input
        virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;


        UPROPERTY(EditAnywhere)
                USceneComponent* OurVisibleComponent;


};




您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

1

主题

4

回帖

225

积分

游客

积分
225