UnrealScripterAI
Discord ↗
Link Copied to Clipboard
×
"when triggered by a player, flips the player's gravity"
AGravityFlipTrigger::AGravityFlipTrigger() { 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, &AGravityFlipTrigger::OnOverlapBegin); } void AGravityFlipTrigger::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult) { // Flip gravity for the overlapping actor OtherActor->GetCharacterMovement()->GravityScale *= -1; }