Grab componennt with mouse

Hello all,

I would like to click on an object with the mouse and then return it to its original position by clicking on the object again. I managed to click on the object with the help of a tutorial on YouTube. But I don’t know how to return it. I use the frist person level.

Best regards,

Jochen

Hi @julmewr ,
Could you share the video you followed as a guide so I can try to replicate it and see if I can give you a hand?

It was this video:

Hello again @julmewr ,

First, I created two Custom Events, GrabItem and DropItem, for cleanliness: I prefer keeping the logic separated, though you can do it without custom events if you want.Then I created a boolean variable IsGrabbingItem. At the end of GrabItem I set it to true, and in DropItem I set it to false.

In DropItem, the first step is to empty the hand: I call Set Static Mesh on the hand component and assign None to New Mesh so the item stops rendering in first person. Then I compute the drop position by taking the Get World Location of the hand/camera and adding the Get Actor Forward Vector multiplied by a distance; that makes it appear a bit in front of the character. With that vector I call SpawnActor and, in Class, I set BP_ITEM to create the actor in the world.

Finally, when E is pressed, I use a Branch with the boolean: if it’s true, I call DropItem; if it’s false, I call GrabItem.
With Custom Events

Without Custom Events

That should do it. For extra realism, in BP_ITEM I enable physics on the Static Mesh so it doesn’t stay rigid when dropped; and I place the Sphere Collision inside the Static Mesh, attached to it

Hope it helps!

Sorry, I made a mistake because I misread the statement. Here’s how to do what you were looking for. In the spawn actor, create a new variable of the vector type and set it to the location where you want the item to spawn.

That should allow you to achieve what you wanted.

Oh wow thank you very much. I try it today.

I have one problem. I can`t find the “Interact” Node.

In the video at 1:37 it shows how to create it, and at 3:47 it implements it. Make sure to use the Array Element pin of the For Each Loop to call the interact node