Passing components to sub-actors (C++)

I am trying to create a set of C++ classes that provide VR functionality. The structure that I am using is that my player Pawn class owns two sub-actors (i.e. classes derived from AActor) for the left and right MotionControllers.

In the BeginPlay() function of my Pawn I have the following:

FActorSpawnParameters SpawnParameters;
SpawnParameters.Owner = this;

LeftController = GetWorld()->SpawnActor<AMotionControllerActor>(FVector::ZeroVector, FRotator::ZeroRotator, SpawnParameters);

On AMotionControllerActor I have the possibility to set a UStaticMeshComponent*, which is used for the visualization of the MotionController ingame. So in AMotionControllerActor I do the following:

UPROPERTY(Category = StaticMeshActor, VisibleAnywhere, BlueprintReadOnly, meta = (ExposeFunctionCategories = "Mesh,Rendering,Physics,Components|StaticMesh", AllowPrivateAccess = "true"))
class UStaticMeshComponent* StaticMeshComponent;

If I would use the MotionControllerActor directly, this allows me to set the mesh from the Details pane of the Unreal Editor. Which is what I want.

However, because I spawn the AMotionControllerActor inside my player Pawn class I can no longer access the MotionControllerActor directly (which makes sense). So I would like to expose the UPROPERTY for the left and right MotionController directly from within my Pawn to the MotionControllerActor. In other words: I want to be able to pass through the UStaticMeshComponent for the Left and Right controller directly from the Details pane associated with the player Pawn to the AMotionControllerActor inside the Pawn.

Maybe this is extremely simple, but somehow I have been unable to come up with a good method to accomplish this.

I did’nt test.

But i will keep the static mesh as UProperty in your Player Pawn
And when you span your subActors, you call a “Initiliaze” method wich take a UStaticMeshComponent* or a class

define your initialize function in your “AMotionControllerActor”

then the call should like:

 FActorSpawnParameters SpawnParameters;
 SpawnParameters.Owner = this;
 
 LeftController = GetWorld()->SpawnActor<AMotionControllerActor>(FVector::ZeroVector, FRotator::ZeroRotator, SpawnParameters);
LeftControler->Initialize(MyStaticMesh);

don’t know if it works but you can then create the mesh and attach it to your rootcomponent.
Hope it helps

Thanks! That does seem to work. It is not my preferred solution (pass through would be more elegant if it were possible), but this will do for now.