-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTP_PickUpComponent.cpp
More file actions
31 lines (25 loc) · 974 Bytes
/
TP_PickUpComponent.cpp
File metadata and controls
31 lines (25 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
ACryptRaiderCharacter* Character = Cast<ACryptRaiderCharacter>(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);
}
}