大佬帮看看什么问题,菜鸟一个,照着官方文档做,报错了
版本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;
};
mknmknmk 发表于 2017-6-10 08:15
找到文档
https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Camera/UCameraComponent/index.h ...
什么意思 为啥没人回复,我用xcode写的也是一直编译不了,为啥 没有引入这个点h文件 这么写就行了:
UPROPERTY(VisibleAnywhere)
class UCameraComponent * FPSCameraComponent;
https://answers.unrealengine.com/questions/672394/strange-error-after-upgrading-to-416.html#
这么写就行了:
这么写就行了::p
页:
[1]