I’m trying to create a scene component that can be attached to an actor, such as a character. This component has a spline component on it, which I will be performing calculations on later. I want the designer to be able to edit the spline path in the editor as with a normal spline path.
The same code works in a custom AActor object, but not in a USceneComponent. I see the spline render in the editor, but I cannot select the points to edit the path.
Here’s the code I’m using:
#pragma once
#include "Components/SceneComponent.h"
#include "TestSplineComponent.generated.h"
class USplineComponent;
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class SPLINETEST_API UTestSplineComponent : public USceneComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UTestSplineComponent();
// Called when the game starts
virtual void BeginPlay() override;
// Called every frame
virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;
UPROPERTY(EditAnywhere, Instanced, Category = "Spline")
USplineComponent* spline;
};
#include "SplineTest.h"
#include "TestSplineComponent.h"
#include "Components/SplineComponent.h"
// Sets default values for this component's properties
UTestSplineComponent::UTestSplineComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
spline = CreateDefaultSubobject<USplineComponent>(TEXT("Path"));
spline->SetupAttachment(this);
spline->bSplineHasBeenEdited = true;
}
// Called when the game starts
void UTestSplineComponent::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UTestSplineComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
// ...
}