making the first person character hold object, when interacted

the title explains itself.

now to the things i made. my character has a srpingarm attached to the camera, so the movement should look more realistic. i added the linetrace function. now i want to pick the object up, when i can interact with it, and place it somewhere else.
any ideas how i can do this? i followed some tutorials, but they were not compatible with the linetrace BP i had.

Sadly, it does not. Normally you’d trace, fetch an actor reference and use it to attach to a component or a socket. Can you explain what’s not working about something like that?

my character has a srpingarm attached to the camera, so the movement should look more realistic.

This is also confusing, why are we mentioning the camera (what is its role in the holding an object system - do you have a separate torso / head movement / control the arms independently?) and why is the springarm attached to the camera? Normally, it’s the other way round. :innocent:

but they were not compatible with the linetrace BP

If you have an issue with something specific, shoot.

i have a normal first person character without a mesh.

i copied the springarm from the one from the flashlight, so it would have a little lag while looking around.

now i got a result, after i changed something. my character is now “holding” the item, but it doesnt shake a little bit, so it looks awful. is there a way to use a similair function like the camera shake function?

So the item is suspended in mid air in front of the character and you need it to have some independent bob-about movement, and you were hoping to use a spring arm for that? Could work… but!

Any reason why you’re not using a Physics Handle? It already does all what you ask. Do tell, perhaps you hate the handle for some good reason. This:

image


I sometimes use springarms for strange things but this seems to work out of the box:

Close to what you need?

thats literally what i was searching for.
but i cannot connect the physic handle to the attach actor to component

Because you should not, the interaction is way more advanced than that, actually, as in: it allows you to do more than just attachment:

Find a tut on that one component specifically. It’s only useful if you want physics. Otherwise it may get iffy. And a springarm (or manual vector interpolation) could work better.


Also, this seems a tad strange:

Shouldn’t we be attaching things inside the player character blueprint? Seems like it’s done inside the held item?

yeah it is done in the item BP and not player BP.

i have 2 types of items. pickable and holdable items.
the pickables should be stored in inventory and holdable in the players “hand”

Don’t want to derail the thread, but are you going to implement this in every actor that needs picking up? And give every object access to the player BP? Sounds like a little nightmare waiting to happen.

Consider doing it in the player if you want to use the springarm:

If you use physics, take advantage of the Physics Handle instead - more natural approach.


You can still use the interface call for something else - like for checking whether this item can be picked up or to make it do something special, play a sound, for example.

Avoid giving random stuff in the world direct access to the player.


the code is now working fine.

the only problem is, that the integers are not correctly transmited between the BPs and i am unable to change the holding item, with the placed one.
i tried to do a “grid” system, where the “ghost” object is invisible and when you are in his near, you can see it. that should show the player where he can put the item he has. after that the “ghost” object should be deleted and replaced with the hold item