BP Static Mesh Component to C++ Actor Component

Hi !

I want to send from a Blueprint a Static Mesh Component to a C++ Actor Component.

Actor Component side:

.h

public:	
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGetStaticMeshComponent);
	UPROPERTY(BlueprintAssignable, Category = "SMC")
	FGetStaticMeshComponent GetStaticMeshComponent;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Settings")
	bool debug;

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Settings")
	TObjectPtr<UStaticMeshComponent> LS_StaticMeshComponent;

	TObjectPtr<UStaticMesh> StaticMesh;

.cpp

void UGCTest::BeginPlay()
{
	Super::BeginPlay();
	
	GetStaticMeshComponent.Broadcast();
	StaticMesh = LS_StaticMeshComponent->GetStaticMesh();
}

void UGCTest::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if(debug)
	{
		if(LS_StaticMeshComponent)
			UE_LOG(LogTemp, Warning, TEXT("LS_StaticMeshComponent Valid"));
	}
}

Blueprint Side:

When I’m pushing play, everything works fine until I’m changing manually a variable at runtime in the detail panel (here “debug”)

The Actor Component BeginPlay is fired back but not the Custom Event " Get Static Mesh Component ", my LS_StaticMeshComponent become invalide and the editor crash with the line
StaticMesh = LS_StaticMeshComponent->GetStaticMesh();

Anyone have a solution?
Thanks !

Instead of a delegate, you could try a Blueprint Implementable Event instead.

Blueprint Implementable Event mixed with BP interface to deal with begin play execution order works perfectly, thanks !