Hey, i got a BP which spawns a bunch of Child Actor Components via AddChildActorComponent. They are all Child Actor Components of derived Actor Classes. The Actor classes are derived from a parent class. I want to use general functions from inside the parent Class for each individual Child Actor Component. Im a bit stuck on how to do it. I thought about communicating between my BP and the parent class, but i got no clue on how to do it with just the Child Actor Component References. I hope you guys can help me.
If you’re spawning child actor components at run time, I suggest just spawning the actor and skip the child actor component.
In order to get the actor that a child actor component has, you need to call Get Child Actor of the component. That will result in the actor, which you can then cast to your custom class.
I don’t really understand what you mean… Could you not just add the child actors in to an array when you spawn them and run your general function inside the parent class through a ForEach loop?
Again, I don’t fully understand your problem so struggling to provide an answer.
Grab from your component and look for “child actor”, then you can cast from here and get your reference (putting them in an array is good idea).
here is an example :
@ste1nar solution worked perfectly^^
My Problem was exactly like @Robnold said (i even had it organized like that, but tried to simplify it), i tried to do the the communication with EventDispatchers and that didnt work that well. Furthermore i thought i tried it like you did @Grot13 but it seems like i didnt, because your solution works perfectly fine too Thank you guys ^^