Hello, I want to know if it’s possible that a UActorComponent to create another component on his owner, I’m going to explain what I’m trying to do
I have a UCombatComponent and my idea is that component creates a USceneComponent on the Actor owner that will be used as projectile spawn point (can be controllable on the editor)
To achieve that I did this:
CombatComponent.h
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
class USceneComponent* SpawnPoint;
virtual void OnRegister() override;
CombatComponent.cpp
// Sets default values for this component's properties
UCombatComponent::UCombatComponent()
{
SpawnPoint = CreateDefaultSubobject<USceneComponent>(FName("Projectile Spawn Point"));
}
void UCombatComponent::OnRegister()
{
Super::OnRegister();
if (GetOwner() != nullptr)
{
SpawnPoint ->SetupAttachment(GetOwner()->GetRootComponent());
}
}
After doing that I can see the USceneComponent on the editor when I attach the combat component to any actor, but the problem is that when I try to move the USceneComponent the position is reset after I compile the BP.
I need to know if there is any solution to that because I want to have the Plug And Play Component approach.
Thanks