Illusion-UE5/hwanyoung2/Source/hwanyoung2/HYAutomaticPickUp.cpp

45 lines
1.0 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "HYAutomaticPickUp.h"
#include "HYPlayerCharacController.h"
// Sets default values
AHYAutomaticPickUp::AHYAutomaticPickUp()
{
// 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;
PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>("PickupMesh");
RootComponent = Cast<USceneComponent>(PickupMesh);
ItemID = FName("No ID");
}
void AHYAutomaticPickUp::Collect_Implementation(APlayerController* Controller)
{
AHYPlayerCharacController* IController = Cast<AHYPlayerCharacController>(Controller);
if (IController->AddItemToInventoryByID(ItemID))
Destroy();
}
FName AHYAutomaticPickUp::GetItemID()
{
return ItemID;
}
// Called when the game starts or when spawned
void AHYAutomaticPickUp::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AHYAutomaticPickUp::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}