Download

Object in a Drawer

Hi, I have made a Blueprint for a Drawer to open and close it with a Lintrace. Now i would put a Object in it. But how can i update the Position of that Object with the Position of the Drawer?

Hey. You may want to use the “AttachToActor” node. Your drawer actor will be the parent and your target will be the object inside.

Try setting the Location Rule to “SnapToTarget”.

I tryed every setting, the Target still don´t move.

If that’s the case, you need to start looking for the bug in other parts of your setup. How did you set up the “Target” variable in the Drawer Blueprint? Are you sure that’s even the right actor? If yes, and the right actor is attached to the drawer, check if you’re moving the whole drawer actor, not just the static mesh attached to the SceneComponent.

What exactly is moving: the “Drawer” actor or just the “Drawer” static mesh component?
If it’s only the static mesh component, then you should use “AttachToComponent” with the Parent as the “Drawer” static mesh component.

From your image, I can see that neither the “Target” nor the “Parent” variables are editable, and since you’re calling this attach on begin play, I get the impression that your references are probably not being set before this attach.

If you have just one variable (Target) for the actor you wish to put into the drawer, then make it editable, you can click your drawer object in the level and set the it as the “Target”.

Remove the “Parent” variable and replace it with “self”, because the blueprint you are working in is the drawer.

It’s quite clear that “Target” is not set, so I repeat the same question as NedimH and Unfathomable: how are you setting “Target”?

Ok, now this one: what is moving? Only the drawer (the static mesh component) or the actor itself? Can you show us what is after the timeline?

If you are just moving the static mesh component, then you should use “Attach to Component” and not “Attach to Actor”.

Here is an example. In this case, an actor BP (a chair) is attached to a platform and move along with it:

As explained in the previous post, use “Attach to Component” with Drawer mesh as the “Parent”.

…it Works… Thnx so much…

But i still get an Error…

A quick fix is adding a “IsValid” node between “Target” and “Target Component”.

And Thnx again… :-))

I see you have multiple drawer objects in your level. Make sure they all have a value set in editor. If you don’t want every drawer to have an object in it you can use “is valid” on the target object to determine whether it has been set. If it hasn’t, do not try execute any nodes that use it (such as your attach function)