UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"script for teleporting the overlapping actor to another location"
ATeleportTrigger::ATeleportTrigger() { PrimaryActorTick.bCanEverTick = true; BoxComponent = CreateDefaultSubobject<UBoxComponent>(TEXT("Box Component")); BoxComponent->InitBoxExtent(FVector(100.0f, 100.0f, 100.0f)); BoxComponent->SetCollisionProfileName(TEXT("Trigger")); RootComponent = BoxComponent; BoxComponent->OnComponentBeginOverlap.AddDynamic(this, &ATeleportTrigger::OnOverlapBegin); } void ATeleportTrigger::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) { // Teleport the overlapping actor to a new location OtherActor->SetActorLocation(FVector(0.0f, 0.0f, 0.0f)); }