Download

Dynamic added components to blueprint - events

Hello,

Is it possible to add events to dynamicly added components during blueprint construction? If so, how?

Can you provide some more data on what you would like to do? An example?

For my root sprite I am spawning (during construction) user edited number of children. Also sprites.
For each component that exists in components list I am able to right click and add OnTouchBegin event. For children of root I am not able to do that as they are not in editor list. To access them I need to iterate through array of children. But there is no option to bind them to event or so.

How are you spawning them? If you are using the “Spawn from Class” you can (I think) bind events to the spawned object node.

I am spawning components to blueprint. As I want this particular bluprint manage all aspects of components. Whle if I use spawn class I am creating new objects not members of this particular blueprint.

I don’t know if it is possible to spawn a component of a blueprint… I don’t think it is.

I would have the Main blueprint spawn the child actors and add them to an actor array, this way the main blueprint can still access all the children by going through the array. You could also look at the “Attach actor to actor” function if you simply want the location of the children to sync up with the moments of the parent.

Hello your solution sounds good.

As per spawning components its possible, there is set of functions add [name] component.

Definitely possible, if you provide more concrete examples we’ll be able to help you with the specifics.

Tip: When you create something dynamically add it to a variable or an array of variables because in-game that’s the only way you’ll have access to them