diff --git a/Source/Nakatomi/NakatomiFieldSystemActor.cpp b/Source/Nakatomi/NakatomiFieldSystemActor.cpp new file mode 100644 index 0000000..21c3800 --- /dev/null +++ b/Source/Nakatomi/NakatomiFieldSystemActor.cpp @@ -0,0 +1,28 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "NakatomiFieldSystemActor.h" + +ANakatomiFieldSystemActor::ANakatomiFieldSystemActor() +{ + SphereComponent = CreateDefaultSubobject(TEXT("SphereComponent")); + SphereComponent->SetSphereRadius(25.0f, true); + SphereComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndProbe); + + SphereComponent->SetupAttachment(RootComponent); + RadialFalloff = CreateDefaultSubobject(TEXT("Radial Falloff")); + RadialVector = CreateDefaultSubobject(TEXT("Radial Vector")); + CullingField = CreateDefaultSubobject(TEXT("Culling Field")); +} + +void ANakatomiFieldSystemActor::BeginPlay() +{ + Radius = SphereComponent->GetScaledSphereRadius(); + Position = GetActorLocation(); + RadialFalloff = RadialFalloff->SetRadialFalloff(StrainMagnitude, MinRange, MaxRange, Default, Radius, Position, EFieldFalloffType::Field_FallOff_None); + 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); +} \ No newline at end of file diff --git a/Source/Nakatomi/NakatomiFieldSystemActor.h b/Source/Nakatomi/NakatomiFieldSystemActor.h new file mode 100644 index 0000000..0e48c4a --- /dev/null +++ b/Source/Nakatomi/NakatomiFieldSystemActor.h @@ -0,0 +1,60 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/SphereComponent.h" +#include "Field/FieldSystemActor.h" +#include "NakatomiFieldSystemActor.generated.h" + + +/** + * + */ +UCLASS() +class NAKATOMI_API ANakatomiFieldSystemActor : public AFieldSystemActor +{ + GENERATED_BODY() + + +private: + + UPROPERTY() + USphereComponent* SphereComponent; + + URadialFalloff* RadialFalloff; + + URadialVector* RadialVector; + + UCullingField* CullingField; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Radial Falloff", Meta = (AllowPrivateAccess = "true")) + float StrainMagnitude = 500.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Radial Vector", Meta = (AllowPrivateAccess = "true")) + float ForceMagnitude = 500.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Radial Falloff", Meta = (AllowPrivateAccess = "true")) + float MinRange = 0.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Radial Falloff", Meta = (AllowPrivateAccess = "true")) + float MaxRange = 1.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Radial Falloff", Meta = (AllowPrivateAccess = "true")) + float Default = 0.0f; + + UPROPERTY(VisibleAnywhere, Category = "Radial Falloff", Meta = (AllowPrivateAccess = "true")) + float Radius = 0.0f; + + UPROPERTY(VisibleAnywhere, Category = "Radial Falloff", Meta = (AllowPrivateAccess = "true")) + FVector Position = FVector::ZeroVector; + +public: + + ANakatomiFieldSystemActor(); + +protected: + + // Called when the game starts or when spawned + virtual void BeginPlay() override; +};