我创建了新项目并添加了新的 c++ 类,但使用 SetupAttachment UE 后出现错误。我试图修复它并找到了一个问题。现在我不知道,在什么问题上,我实际上知道这个地方。构建后的 UE5 窗口
代码:
标题:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "TankController.generated.h"
class USpringArmComponent;
class UCameraComponent;
UCLASS()
class TANKS_API ATankController : public APawn
{
GENERATED_BODY()
public:
// Sets default values for this pawn's properties
ATankController();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
//DEFINTE COMPONENTS //
// Do a Hull of the Tank
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
UStaticMeshComponent* Hull;
// Wheels for the Tank
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
UStaticMeshComponent* Wheel1;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
UStaticMeshComponent* Wheel2;
//Tower of the Tank
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
UStaticMeshComponent* Turret;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
UStaticMeshComponent* Barrel;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
UStaticMeshComponent* RecoilSystem;
// Camera Components
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
USpringArmComponent* SpringArm;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Components")
UCameraComponent* Camera;
public:
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};
和 cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "TankController.h"
#include "GameFramework/SpringArmComponent.h"
// Sets default values
ATankController::ATankController()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
// Set Root Component to ours Hull
RootComponent = Hull;
// Attach Wheels to the Hull
// Here i have an error
SpringArm->SetupAttachment(Hull);
}
// Called when the game starts or when spawned
void ATankController::BeginPlay()
{
Super::BeginPlay();
}
// Called to bind functionality to input
void ATankController::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
如何解决此错误?是我的错误,还是UE的错误?