Download

Adding Component Dynamically During Runtime?

I wrote a few component scripts and would like to add them to the player pawn under certain conditions.

Here is something I did as an experiment:
I added a new health component script during runtime to the player, it seems to work. Health deducts correctly.
1a7ba4041d49ea713374510531b5e0cecebca9c0.png

But when I hover over the add component node, it says do not call this manually.
9f0176b5440033751d29dac043ec517fa7e4ef5a.png

Is it bad to add component scripts during run time? What is the best way to add component scripts dynamically to actors?

Exact same situation. Pending ideas…

I have seen that plenty of times in many of the blueprint nodes I use. Unless someone else has evidence to the contrary, I’d say they’re safe to use. I haven’t had any problems with any that I’ve been using.

That is good to know. I will be using it for now until someone says otherwise. I will also post an update if I encounter any issues.

I’m fairly certain that this is nothing to do with adding components at runtime, instead it’s most likely telling you never to call that function in C++ as it’s only for use with the internal blueprint parsing… There’s zero problems with adding components at runtime, as that’s what blueprint does really well. It’s referring to the “UK2Node_AddComponent” function so clearly it’s making sure that you never call that function manually in C++.