Can I set a blueprint actor as a component for another blueprint actor?

I want to add one blueprint actor as a component to an another blueprint actor. I make an empty component slot on the one to which I attach and set the transform so that it will appear in the right place when I call “Set Component”. But I don’t know which component type I need to select to make this work. As far as I can tell it’s just straight up impossible.

My current idea is to get the static mesh component of my blueprint that is supposed to get attached and then attach that static mesh component to the predetermined position.

What I want to do is to put a piece of paper inside a glass chamber, do something with the paper while it is in the chamber and then take it out again after. But I don’t know if I can just attach the static mesh component of my BP that is supposed to get attached, leave it in the BP of the chamber for a while and then take it out and have the info retained by the static mesh component.

Here’s a small explanation of what I’m trying to achieve.

Here’s my current node setup inside BP_DC_Chamber

Right now I don’t know how to access the right child component so that is is compatible with Set Static Mesh.

What you want to happen can just be done by using the AttachActorToActor node. Whenever the player interacts with the chamber while holding the paper, that can send a signal to the chamber with a reference to the paper. The chamber can then force the paper to attach to it, and set it’s location. You can then use the stored reference to the paper to further modify it however you want.

Also I would recommend making a CanInteract function in that Interact interface. So instead of checking if you are holding a paper, the chamber itself can check- the pawn itself doesn’t have to know that it needs to be holding paper to interact with a certain object. It’s also very useful for getting the paper back- if that’s what you want. This cleans up your logic a lot.

will it take the paper out of my hand and reset the physics handle when I use attach to actor?

You’ll probably need to properly sever the connection to the player first- before using attach actor to actor. There is an option to weld the bodies on the node, but I’m not sure if that’s what you want.

add child actor component :face_in_clouds:

1 Like

Yes, but that essentially does the exact same thing as Attach Actor to Actor, except less practical. You can’t pass in a class to create, while you can see the actor in the outliner- you can’t change anything on it, and above all that wouldn’t be useful in this situation because the actor is already created, and needs to be able to be swapped between different actors.

Though, I didn’t know about this node. Thanks for bringing it up

That is false, and can also be exchanged between different actors.

I meant change anything on it through the outliner. I am not sure how you are supposed to move it, but feel free to tell me. I am always eager to learn new methods

That is true but you can get the variables of the child actor in the event construct of the parent and expose to use in the editor outliner.

like any other component

but back to the @ecksdeeeee question, maybe the best solution is have a hidden paper inside the box, that paper copy the real paper propieties and turn visible when interact, do any change u want with the fake, when the interaction ends copy the fake propieties to the real.

Not sure if I missed something critical above but the 2 solutions that spring to mind:

  • child actor component: now you have an actor attached to another actor that behaves like a component would
  • override a static mesh component and use that: now you have a component with a full graph and functionality

The latter works especially well since it’s now (v4.26 and up) trivial to spawn components from class.


edit:

I see now it was mentioned already.

what are the nodes that I need to use for that?

Not 100% certain I understand what needs to be done (despite the cool graph!).

We’re holding a component and want to get its mesh and assign it as the mesh of the paper slot?

Or is it going to be more complex, because it often is?


Stick with me, trying to wrap my own mind around it :smiley:

In layman’s terms:

  • we (the player?) hold a sheet of paper (grabbed component, right?)
  • we interact with the chamber (an actor?)
  • if the interaction is valid, the chamber now holds the paper
  • the chamber must own or have access to the paper so it can access it, too
  • we will extract the paper

How close am I? And, if so:

  • is there ever going to be something else than paper we can hold and stuff in the chamber
  • is the paper / items supposed to run logic of their own (hold data - as in, the paper has dynamic text and pictures that can be updated)

yep, that about sums it up. this is a virtual version of an experiment called “Thin-layer chromatography”.

What you do is to put a sheet of special paper in a chamber that is filled with liquid and let the liquid run up the paper due to capillary forces. So basically, there is a bunch of solvent at the bottom of the chamber and the paper soaks it up so that a linear front of solvent propagates up the paper upwards. I made a small explanation in powerpoint to keep it comprehensible.

So both the chamber as well as the paper need to be blueprints as far as I can tell.

  • override the static mesh component:

  • now you have a specialised component that not only hosts a static mesh but can also store data and run logic internally:

  • actors can now add that component:

image

  • or, as you originally envisioned it, have a variable in the Chamber actor (here, PaperInChamber) of the appropriate type (myPaper) reference it and then attach this custom component to the Chamber actor:

When you pull it out, you can detach it.