UE中的Actor建立

新建C++类,继承Actor蓝图

C++代码:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Floater.generated.h"

UCLASS()

//继承了Actor类
class MYC_TEST1_UOBJECT_API AFloater : public AActor
{

//主体
GENERATED_BODY()

public:
// Sets default values for this actor's properties,名字
AFloater();

//主体类型可见,表情名

UPROPERTY(VisibleAnywhere,Category="ActorMeshComponents")

//网格体指针
UStaticMeshComponent* StaticMesh;
protected:
// Called when the game starts or when spawned

//开始事件
virtual void BeginPlay() override;

public:

//声明Tick事件
// Called every frame
virtual void Tick(float DeltaTime) override;

};

 

// Fill out your copyright notice in the Description page of Project Settings.


#include "Floater.h"

// Sets default values
AFloater::AFloater()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;

//默认object,静态网格体,组件命名

StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CustomStaticMesh"));
}
// Called when the game starts or when spawned开始事件
void AFloater::BeginPlay()
{
Super::BeginPlay();

}

// Called every frame,Tick事件
void AFloater::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

}

 

posted @ 2022-08-20 01:06  hanabc12345  阅读(197)  评论(0)    收藏  举报