我正在使用虚幻4.18和Visual Studio 2017。使用某些类,如UShapeComponent,UBoxComponent,USphereComponent给出标识符是未定义的错误,而像USceneComponent,UStaticMeshComponent工作得很好。怎么了?
这是我的代码:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class UNREALTUROIAL_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere)
UStaticMeshComponent* PickUpMesh;
UPROPERTY(EditAnywhere)
UShapeComponent* PickUpBox;
UPROPERTY(EditAnywhere)
USceneComponent* PickUpRoot;
};
在此处输入代码您可以尝试将此包含添加到您的 .h 文件中
#include <Runtime/Engine/Classes/Components/SphereComponent.h>