Set material in a child actor blueprint from aother actor blueprint (Running only in Construction script)

Hello pepz.

Really hope some of you can know the answer to this one.

I’m creating a system that will only run in construction script. The whole system run from one blueprint, lets call this Blueprint A

Blueprint A has some Child actors ( Child actor Bluepirnt B and C) which contain meshes. It must be possible to change material on these meshes in Bluepirnt B and C from Blueprint A in the de detail panel.

How could such a system/visual code look like?

How can I change material in a child actor bluepirnt from another actor blueprint all inside the construction script ?

Does “Cast to” or “interfaces” run in editor?

Like this

Using child actor blueprints is a pain in the buum.

1 Like

Thanks for the quick reply! :star_struck:

I got it to work but now I ran into another problem :sweat_smile:
The Child Actor Blueprint B and C must be dynamic to replace, it must be possible to replace them with another bluepirnt.

For example:
Blueprint B can be replaced with a Blueprint D which also contains meshes

I’ve been thinking of building it with structs. but I can not select specific blueprint actors in structures

Then, you need to add the child in the construction script

and then set it again…

I’ll just add that this is a convenient method for CACs:

Instance Editable variables are accessible at this point so the functionality can be contained in the actor itself.

May not be applicable in this very scenario, though… It would be nice if we could override the CAC in BPs like one can override the Widget Component and simply expose data pins :expressionless:

1 Like

By doing this, Do I need to replace the “cast to” for the “Add Child Actor Component” or how should this be implanted?

Is any of this right? - how do I get the meshes out and into the “Set Material” Child Actor Component?

Child Actor (the node at the very bottom) → Cast To (actor the CAC has) → get static mesh → Set material. As in the 2nd post. Or to be very specific:

Okay. I just thought there might be a way around the “cast to node”, so that the user dont have to replace a new cast node every time they switch blueprint in “Child actor component variable”

But thank you for the answers and you time. both of you, I really appreciate it :slight_smile:

Use an interface. No casting. No need to replace anything. Instead of the cast you’d send an interface message, and the receiving Child Actor can interpret it any way they need.

Does interfaces work in “construction script” ?

Not sure how to answer that. Interface calls a function. You can’t call an actor that has yet to be instantiated. If you’re worrying about actor popping up with the wrong material, it’s extremely unlikely. But you can always spawn it hidden, change material and then show it.

  • if this is the interface

  • and this is the implementation in the target child actor:

  • you could call it like so:

brought to you by Interface Messaging 100% cast free…

I thought of using blueprint interface before but I only thought it run in runtime?
The system is not meant to run at runtime.

Yeah, I missed that bit. But the actor does exist at this point. It should work as is.