I’ve been trying to create a weapon component deriving from UActorComponent (and a custom interface). here’s the code I’m using in the constructor of the actor owning it:
DefaultWpn is an instance variable of type UDefaultWeaponComponent*. Here’t the “but”, when I run the game, the component is not visible in the component list of the actor, nor can I use its methods. Am I doing something wrong?
i think it’s because you’re not doing the “SetupAttachment()” that has to be done after creating a SubObject so its spawning in world 0,0,0
DefaultWpn = CreateDefaultSubobject(“Big gun”);
DefaultWpn->SetupAttachment( // RootComponent, or another component, or a socket, or whatever you want );