How to AddChildActorComponent with dynamic values?

Hello,

So I’m playing with blueprints (noob in UE) and trying to do the same stuff in different ways. Mainly trying to reproduce some POE mechanics. What I want to do is :

  • Spawning a projectile that chain (bounce between actors) automatically

I have something that works where :

  • My main BP (spell) has a function that spawns a “ChainingProjectile_BP” actor
  • The “ChainingProjectile_BP” has variables such as the projectile speed or the number of chains but no physical element, just a rootcomponent.
  • This actor will spawn a “primary_projectile” actor (actual physical projectile) which, upon overlapping an ennemy A, will return a bunch of info to my “ChainingProjectile_BP” via Interface. It is then destroyed.
  • The “ChainingProjectile_BP” checks if there is a target in range (ennemy B) of the hit location with A, and will spawn a new “primary projectile” that goes from A toward B.

So this working perfectly but I’ve just learned about “AddChildActorComponent”. It would be super handy in this case because I could have all these actors with proper hierarchy inside a single actor and then access the children very easily (in case I want for example to spawn new chaining projectiles from current live projectiles, because why not)


The problem is that I cant find a way to set the values inside an “AddChildActorComponent” node dynamically. I can only edit them in the editor and I have no way to access them at run time (for example, the transform for each child is accessible from the node, but not the rest )

: is there a way I could “Add a child component” and set its default values dynamically ?**

Thank you for your help!

Hey lLeibniz,

I think you have to change values right after you create the child component.

(Afcorse you don’t want to cast to Box component but to your “ChainProjectile_skill_v2”)

Hey ! ty for the help

So if I want to make a flexible system I would need to :

  • AddChildActorComponent with the class “none” by default
  • Set the class afterward, then set the world transform for it
  • Then cast to the child actor
  • Then only change its default values

Why is that so much more complicated than when spawning an actor ? If I understand correctly, I need to first spawn the child with fake/default values, and only then tell it who/where and what he is.

Is there not a way to specify those before creating the child ? that would seem so much more efficient… but what do I know…

1 Like