I know this thread is very old, but it’s one of the first results on google when trying to look up what the concept of “Activation” in a component means, so I wanted to provide some of my findings here.
In short, I think Activation/Deactivation doesn’t do anything by itself. If you want Activating/Deactivating a component to run some logic, you NEED to bind to the OnComponentActivated and OnComponentDeactivated event dispatchers.
Here’s a tangible example of how I’m utilizing component activation in my project:
I have an actor component called AC_TimerController. It is used to control the main timer in my game, and create/update the widget used to display the amount of time left.
The original way I had it set up was that anytime my game needed a timer, my GameState would run the AddComponentByClass node to create a new instance of AC_TimerController inside of GameState. AC_TimerController’s BeginPlay would automatically create the timer widget, and the Event Tick would update it.
If my game no longer needed a timer, I’d destroy the AC_TimerController component inside of GameState. AC_TimerController’s EndPlay would automatically destroy the widget it had previously created.
This worked fine, but it felt weird to constantly create/destroy AC_TimerController, especially since I knew I’d only ever want one timer on the screen at a time. Activating/Deactivating the component felt exactly like a concept I wanted to apply here, and after digging around and doing my own experiments, this is how my timer system looks now:
AC_TimerController is already inside of my GameState by default. AC_TimerController’s “Start with Tick Enabled” is set to false, and in its BeginPlay, I bind functions to both OnComponentActivated and OnComponentDeactivated, as shown here:
OnActivate does a few boilerplate things to get the timer controller ready, as well as creates the timer widget itself, but importantly, it enables the component’s tick:
OnDeactivate does basically the opposite of the things above; it removes the created widget and sets the component’s tick enabled to false.
Now, whenever I want my game to start a timer, I can simply Activate the AC_TimerController inside of my GameState:
Activating it will call its OnActivate function, which does all the boilerplate stuff I showed in a previous screenshot. When I’m finished with the timer I can then run the Deactivate node in order to run all of my OnDeactivate logic.
While this feels much better than creating/destroying AC_TimerController whenever I wanted a timer, I can’t shake the feeling that it’s somewhat overengineer-y. In the above StartMainGame event, I could have easily just called AC_TimerController’s OnActivate function to achieve the same results.
However, I know there’s a number of other functionalities I can use with regards to Activation listed in the docs here, which maybe I’ll find useful later down the line. The above setup also allows me to make other actors bind functions to AC_TimerController’s OnComponentActivate dispatcher, so I could for example make a streetlight turn green when AC_TimerController is activated, or something.
Anyway, I’m not sure if I’m applying the concept of Activation the way the UE devs intended, but what I listed above works for me. I hope this info helps anyone in their search-engine treks learn a bit more about what Activate does to an actor/scene component