Download

Can I add a blueprint as a component of another blueprint?

I have a blueprint (A), and I’d like to add it as a component to another blueprint (B). I can drag A onto B, and it does show up in B’s components list and Viewport, but I can’t access any of A’s variables. Instances of A in my level have variables that can be modified in the details pain and via a 3D Widget (for a vector variable), but in B’s viewport, I cannot access these variables at all. I should also point out that I will need A’s construction blueprint to fire within B (like it does in the level).

Is it possible to add a blueprint as a component of another blueprint, and to access the component blueprint’s variables and call its construction script?

Thank you.

Read about blueprintable components, that is closest to what you want (i think so).

Other a bit similar things:
There are also child actor components (that is just attached another blueprint).
And you can use inherited blueprints.

To access other blueprint variables you usually need to do some magic.
Learn this stuff:

  • blueprint interfaces
  • event dispatchers

Also there are usually some ways to get parent reference then cast to its class (or use interface call), those are multiple nodes depending which way you communicate and what those blueprints are.

Thank you for your response. I think I’m getting closer.

I don’t think blueprintable components get me what I want. I need a construction script (which they don’t appear to have).

I am presently using a child actor component. Blueprint A is a child actor component on B. I was also able to confirm that A’s construction script is getting called, which is good. Now all I need to be able to do is set its variable values.

Blueprint interfaces are a good thought, but the interface function doesn’t seem to be firing. I have a log calls in both the consuming blueprint (B) and the implementer blueprint (A), and only the former fires.

That lead me to exposing a custom event, which does appear to work to a degree. Blueprint A now has an event called Tester. Blueprint B’s construction script calls Tester, which sets a variable to 4. Using Print String, I have confirmed that the following is happening (in this order):

  • Blueprint A’s (the child actor component blueprint) construction script is called.
  • Blueprint B’s (the parent blueprint) construction script is called, calling Tester.
  • Tester fires, setting (confirmed with logs) the variable’s value from 2 (its default value) to 4.
  • Blueprint A’s construction script is called again (which is what I want), but the variable’s value is now set back to 2 (confirmed with logs).

That is really close to what I want. The only problem is that bold part. I’m assuming that when Blueprint A’s construction script fires for the second time, it is resetting the variable’s default value (to 2), but I need it to retain its value of 4 (which was set just a moment ago by Blueprint A’s event, Tester).

How can I get the construction script to use the variable’s current value when it is called the second time, and not its default value?

Thank you for your help.