I’d like to make a USceneComponent to add movement to objects. So I made one that creates a USplineComponent and adds it to its parent AActor:
in the .h:
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement")
USplineComponent* MovementSpline;
in the .cpp:
UBSMovementComponent::UBSMovementComponent()
{
PrimaryComponentTick.bCanEverTick = true;
AActor* Owner = GetOwner();
if (Owner)
{
USceneComponent* OwnerRootComponent = Owner->GetRootComponent();
MovementSpline = CreateDefaultSubobject<USplineComponent>("MovementSpline");
MovementSpline->SetupAttachment(OwnerRootComponent);
...
The spline appears in the editor (though not in the components area). But when I select a control point, then try to edit the location of the control point…
…the whole actor moves instead!
The same code works if it is just added to an AActor, but not when it is done with a component. Am I doing something wrong?