I haven’t been able to find any details online whether to use RegisterComponent or Activate, nor what the difference is; so, the first part the of the question is when to use RegisterComponent() or Activate()?
I would normally test this out and see what happens when either is called, but the kicker is I can’t get either to work. In my header, I have the whole UCustomComponent* MyComponent deal, but putting either MyComponent->RegisterComponent() or MyComponent->ActivateComponent() in my actor’s BeginPlay crashes the editor on play; I tried putting them instead in the actor’s constructor, but that corrupted the project and I had to rebuild Intermediate and Binaries.
But you created first component itself, before call any functions for it? That’s description for RegisterComponent method:
/** Register this component, creating any rendering/physics state. Will also adds to outer Actor's Components array, if not already present. */
And that’s description for Activate method:
* Activates the SceneComponent
* @param bReset - The value to assign to HiddenGame.
virtual void Activate(bool bReset=false);
So Activate just starts(or restarts) component’s tick timer and enables Tick function if it was disabled. RegisterComponent register it inside it’s owner and inside owner’s world.
But before call above methods you must create component itself. If you want to create it within constructor then you can call CreateDefaultSubobject(…) method. If you want to create it dynamically then you can call NewObject method (but I didn’t test it this way, so check these 2 links if you want: first, second)