Actor creation and attachment in constuctor

I have an “InteractiveObject” class based on Actor which has the following:

  • a root node
  • a StaticMeshComponent
  • various user interaction functions like MouseOver(), MouseOff(), MouseClick(), etc.

Works great, but now I would like to compose interactive objects into equipment with various “InteractiveObjectComponents”. For example:

  • a base equipment cabinet (“InteractiveObject”)
  • a door to open the cabinet (“InteractiveObjectComponent”)
  • a handle to unlatch the door (“InteractiveObjectComponent”)
  • various electronic parts inside the cabinet (“InteractiveObjectComponent”)
  • etc…

The parent-child attachment can be arbitrarily deep (e.g. cabinet <- door <- handle) so I’m pretty sure they all have to be Actors?

Anyway, I’m having a bit of trouble creating and attaching the components in the base object’s C++ constructor. Anyone know of any examples of how to:

  • create an actor
  • assign it a static mesh
  • attach it to another actor in the constructor (or wherever, it just has to show up in the editor and game)

The “InteractiveObjectComponent” needs to function similarly to StaticMeshComponent but with additional custom functionality for user interaction.

Welp, solved this in a fairly easy way by just extending the StaticMeshComponent class into an InteractiveStaticMeshComponent.

class MCSGAME_API UInteractiveStaticMeshComponent : public UStaticMeshComponent
   // add custom functionality for MouseOver(), MouseOff(), Select(), Deselect(), etc.