1。新建一個基類,用于玩家可拾取物品的父類
然后
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "Components/SphereComponent.h"
#include "GameFramework/Actor.h"
#include "XMBPickUpBase.generated.h"UCLASS()
class ARPG_GRIVITY_API AXMBPickUpBase : public AActor
{GENERATED_BODY()public: AXMBPickUpBase();protected://UPROPERTY(VisibleAnywhere,BlueprintReadOnly,Category = "Pick Up Interaction")USphereComponent* PickUpCollisionSphere;//UFUNCTION()virtual void OnPickUpCollisionSphereBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);};
// Fill out your copyright notice in the Description page of Project Settings.#include "Items/PickUps/XMBPickUpBase.h"
#include "Components/SphereComponent.h"// Sets default values
AXMBPickUpBase::AXMBPickUpBase()
{PrimaryActorTick.bCanEverTick = false;PickUpCollisionSphere = CreateDefaultSubobject<USphereComponent>(TEXT("PickUpCollisionSphere"));SetRootComponent(PickUpCollisionSphere);PickUpCollisionSphere->InitSphereRadius(50.f);PickUpCollisionSphere->OnComponentBeginOverlap.AddUniqueDynamic(this,&ThisClass::OnPickUpCollisionSphereBeginOverlap);}void AXMBPickUpBase::OnPickUpCollisionSphereBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{}
再創建該類的子類,用于制作玩家可拾取的功能性石頭道具
2。再根據創建的子類創建一個藍圖,做為藍圖的基類,往里面添加一個niagara
在創建此藍圖的子類,用于分類不同功能的可拾取性道具