UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"script for when player triggers pickup function"
APickupTrigger::APickupTrigger() { PrimaryActorTick.bCanEverTick = true; SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere Component")); SphereComponent->InitSphereRadius(100.0f); SphereComponent->SetCollisionProfileName(TEXT("Trigger")); RootComponent = SphereComponent; SphereComponent->OnComponentBeginOverlap.AddDynamic(this, APickupTrigger::OnOverlapBegin); } void APickupTrigger::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) { // Pick up the overlapping actor OtherActor->Destroy(); }