Hi there,
Here is a code snippet I transferred from non-plugin into a plugin.
Before it was a plugin, I never had to add include headers.
Now it is not only required for me to be able to package the plugin, but it asks it in the header.
I find it odd that I would have to include headers when I have their Modules as public dependencies in the plugin’s .Build.cs file.
Am I missing something?
#pragma once
#include "Components/ActorComponent.h"
#include "GameFramework/Actor.h"
#include "Engine/World.h"
#include "SinOscillation.generated.h"
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class LUDWELLUNREALMATH_API USinOscillation : public UActorComponent
{
GENERATED_BODY()
public:
USinOscillation();
protected:
virtual void BeginPlay() override;
public:
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(Category = "Ludwell|Math", BlueprintCallable)
void Oscillate() const;
private:
FVector InitialLocation;
UPROPERTY(Category = "Values", EditAnywhere)
FVector Amplitudes = FVector(1.0f, 1.0f, 1.0f);
UPROPERTY(Category = "Values", EditAnywhere)
FVector Frequencies = FVector(1.0f, 1.0f, 1.0f);
};
// Oscillate from the source file
void USinOscillation::Oscillate() const
{
const float Time = GetWorld()->GetTimeSeconds();
const float NewX = Amplitudes.X * FMath::Sin(Time * Frequencies.X);
const float NewY = Amplitudes.Y * FMath::Sin(Time * Frequencies.Y);
const float NewZ = Amplitudes.Z * FMath::Sin(Time * Frequencies.Z);
const FVector NewLocation = InitialLocation + FVector(NewX, NewY, NewZ);
GetOwner()->SetActorLocation(NewLocation);
}