Actor as component of actor?

Is there a good way to connect an actor as a component to another actor?
Even that is not necessary, I can even get a way with an actor having a refernce to a spawned actor.
But how do I keep the reference.

What I tried to do is:

Add a ChildActor Scenery and set it to the typ BP_Scenary.

Spawn the SceneryObject BP_Rock;
Tried to set the ChildActor to BP_Rock;

BP_Rock Derive from BP_Scenery.
Can’t set it.

Need to cast it to BP_Scenery before setting it?
Can I even set it like that?

Thanks in advance.

By “ChildActor Scenery”, I take it you mean you added a child actor component in the components tab of the parent BP?

If so, then it sounds like you are trying to set that to a reference of a already spawned actor? That isn’t how the child actor component works. The child actor component will automatically spawn a new actor of the type it is set to. It then sets this new actor to the position of the child actor component (relative to the parent blueprint).

So if I am understanding you correctly, then you would add a child actor component, and set it’s actor type to “BP_Rock”, then whenever a instance of the parent actor is spawned/added to the scene, then it will also create a new child actor of the “BP_Rock” type.

The problem is that I don’t want to define what to spawn before the type is set in the editor or during run time.

What I want to do is to create a number of ground tiles, then based on settings on the tile, spawn the corresponding Scenery detail on top, and this object might also dynamically change later, but it is part of the tile.

So simply put I want a child object of the tile, I don’t want that child object to be ALL TYPES of possible objects, but create separate blueprints that extend out of a common parent class.

In c++ I would just have a

BP_Scenery* child;
TileTypes tileType;

on the change of tileType I would destroy the current child if any and create an instance of the new Child Type I want.
switch(tiletype)
case ROCK:
delete child;
child = new BP_Rock();
case ARROW_LEFT:
delete child;
child = new BP_ARROW_LEFT();

Hello,
if i had to do that i certainly would use 2 arrays and a static mesh variable. One array register all my static meshes and the other register my grid reference. Variable is a static mesh one in my grid square.
On event if grid array square variable is filled with a mesh then get mesh component and destroy component. Then set new variable value and add static mesh.

But the problem here is that we are not just talking about a mesh, I want it as blueprint to allow the blueprint to specifit the logic of the object, yes it might just be a mesh, but it might be an animated mesh, a particle system, or combination, controlled by it’s own defined blueprint, with a shared set of information from the scenery blueprint. It could be a rock, a fountain, a gate, a fence. The only common thing is that they have a fixed spot above the ground and a shared class for some basic placement and behavior. This should be doable. I just my base tile to have a reference to the object, whatever it might be, there for a base class.

do you can show the blueprint?

Then try “add child actor component”. I haven’t tried it but it seems that the spawn / despawn is easier than a add component. Maybe you’ll can add a blueprint. If not, based on my first idea, i would do a cast to blueprint to drag infos and effects but as it will only be a generic set, i would do a parent bp with common variables for all meshes and use that. (meaning registering infos like : effect1 var / effect2 var particle var custom event 1 function 1 and make particular set in child but all with the same name to call from a cast to parent )

edit : but i suppose that some settings will be needed to have this working, maybe only a mesh array in one blueprint but as it is only calling functions, setting them in your level blueprint seems better faster cleaner idea…

More infos would be great to try to find an interesting solution.

Ok.

I was thinking more about this.
The actor doesn’t need to be a component of the original actor.
There for I could rather have a offset node as a component, just describing the world position, and a var to the new actor.
I am going to test this now and see if it works better.

Yes. I was thinking all wrong.
One should not mix up actor components and variables.
The simple solution was to add a SceneComponent to the BluePrint, this gives me the possiblity to specify where I want the new object to appear.

Next step, use the enum value i exposed in the tile. use the switch on tile type to specify what actor to spawn. Then finally set the actors transform to be the same as the SceneComponents.

Problem solved. It was just a total brain fart and an assumption that the component hierchy were or could be unspecified actors.

So this is the current end result, the tile set to type “Rock” spawn the rock BP on top of them. The variable i reference is called ChildActor. The next step is modify/alter this value on click.
But that should be trival, have already added a function to get the actor from under the mouse. Now I just need to feed in the click and pass that on to the child.
09d6f624279063de97c4c16c615f3e20e17974a7.jpeg