First commit
This commit is contained in:
31
Source/ProjectLighthouse/TP_PickUpComponent.cpp
Normal file
31
Source/ProjectLighthouse/TP_PickUpComponent.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "TP_PickUpComponent.h"
|
||||
|
||||
UTP_PickUpComponent::UTP_PickUpComponent()
|
||||
{
|
||||
// Setup the Sphere Collision
|
||||
SphereRadius = 32.f;
|
||||
}
|
||||
|
||||
void UTP_PickUpComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
// Register our Overlap Event
|
||||
OnComponentBeginOverlap.AddDynamic(this, &UTP_PickUpComponent::OnSphereBeginOverlap);
|
||||
}
|
||||
|
||||
void UTP_PickUpComponent::OnSphereBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||
{
|
||||
// Checking if it is a First Person Character overlapping
|
||||
AProjectLighthouseCharacter* Character = Cast<AProjectLighthouseCharacter>(OtherActor);
|
||||
if(Character != nullptr)
|
||||
{
|
||||
// Notify that the actor is being picked up
|
||||
OnPickUp.Broadcast(Character);
|
||||
|
||||
// Unregister from the Overlap Event so it is no longer triggered
|
||||
OnComponentBeginOverlap.RemoveAll(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user