求带6666666 发表于 2017-6-9 21:18:01

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

版本4.16
刚接触
照着官方文档入门,报错了。
https://docs.unrealengine.com/latest/CHN/Programming/Tutorials/PlayerInput/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::Player0;
        // 创建一个可供添加对象的空根组件。
        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/questions/672394/strange-error-after-upgrading-to-416.html#

iugoddess 发表于 2018-11-30 14:41:36


这么写就行了:
这么写就行了::p
页: [1]
查看完整版本: 大佬帮看看什么问题,菜鸟一个,照着官方文档做,报错了