Nakatomi/Source/Nakatomi/NakatomiFieldSystemActor.cpp

32 lines
1.4 KiB
C++
Raw Normal View History

2023-01-31 22:25:28 +01:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "NakatomiFieldSystemActor.h"
ANakatomiFieldSystemActor::ANakatomiFieldSystemActor()
{
SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComponent"));
SphereComponent->SetSphereRadius(25.0f, true);
SphereComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndProbe);
SphereComponent->SetupAttachment(RootComponent);
RadialFalloff = CreateDefaultSubobject<URadialFalloff>(TEXT("Radial Falloff"));
RadialVector = CreateDefaultSubobject<URadialVector>(TEXT("Radial Vector"));
CullingField = CreateDefaultSubobject<UCullingField>(TEXT("Culling Field"));
2023-06-23 22:06:18 +02:00
SphereComponent->SetCollisionResponseToAllChannels(ECR_Overlap);
2023-01-31 22:25:28 +01:00
}
void ANakatomiFieldSystemActor::BeginPlay()
{
Radius = SphereComponent->GetScaledSphereRadius();
Position = GetActorLocation();
2023-06-23 22:06:18 +02:00
RadialFalloff = RadialFalloff->SetRadialFalloff(StrainMagnitude, MinRange, MaxRange, Default, Radius, Position,
Field_FallOff_None);
2023-01-31 22:25:28 +01:00
GetFieldSystemComponent()->ApplyPhysicsField(true, Field_ExternalClusterStrain, nullptr, RadialFalloff);
RadialVector = RadialVector->SetRadialVector(ForceMagnitude, Position);
CullingField = CullingField->SetCullingField(RadialFalloff, RadialVector, Field_Culling_Outside);
GetFieldSystemComponent()->ApplyPhysicsField(true, Field_LinearVelocity, nullptr, CullingField);
2023-06-23 22:06:18 +02:00
}