Solved this by creating a new project entirely… encounter another problem when tried adding my new code in it…
(since this is new project, i use different name file)
Pick.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Pick.h"
#include "Components/StaticMeshComponent.h"
#include "Components/BoxComponent.h"
// Sets default values
APick::APick()
{
// 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;
PickupRoot = CreateDefaultSubobject<USceneComponent>(TEXT("PickupRoot"));
RootComponent = PickupRoot;
PickupMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("PickupMesh"));
PickupMesh->AttachToComponent(PickupRoot, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
PickupBox = CreateDefaultSubobject<UBoxComponent>(TEXT("PickupBox"));
//PickupBox->SetWorldScale3D(FVector(1.0f, 1.0f, 1.0f));
PickupBox->bGenerateOverlapEvents = true;
PickupBox->OnComponentBeginOverlap.AddDynamic(this, &APick::onPlayerOverlapPickupBox);
PickupBox->AttachToComponent(PickupRoot, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
}
// Called when the game starts or when spawned
void APick::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APick::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void APick::onPlayerOverlapPickupBox(UPrimitiveComponent* overlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
Destroy();
}