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

[复制链接]
查看3538 | 回复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;


};




aikevan | 2017-6-14 09:17:26 | 显示全部楼层
mknmknmk 发表于 2017-6-10 08:15
找到文档
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Camera/UCameraComponent/index.h ...

什么意思
回复 支持 反对

使用道具 举报

aikevan | 2017-6-14 09:18:11 | 显示全部楼层
为啥没人回复,我用xcode写的也是一直编译不了,为啥
回复 支持 反对

使用道具 举报

aikevan | 2017-6-14 10:07:46 | 显示全部楼层
没有引入这个点h文件
回复 支持 反对

使用道具 举报

LRyir | 2017-8-12 17:38:00 | 显示全部楼层
这么写就行了:
UPROPERTY(VisibleAnywhere)
class UCameraComponent * FPSCameraComponent;

https://answers.unrealengine.com ... rading-to-416.html#
回复 支持 反对

使用道具 举报

iugoddess | 2018-11-30 14:41:36 | 显示全部楼层

这么写就行了:
这么写就行了::p
回复 支持 反对

使用道具 举报

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

本版积分规则

1

主题

4

回帖

225

积分

游客

积分
225