Destroying the object is causing errors.

Hello, I’m facing a problem with my blueprint. I have implemented a pickup system where there is an empty placeholder in front of the camera of the first person, so that when the player picks up an object, it destroy the object and place it in the place holder. and for putting down, I’m doing the opposite, when clicking on the spot I want to put the object in, I destroy the item that the user is holding and turning on visibility of the object on that spot. This is working but only for the first item being picked and put down. When there are more than one item to be picked, the second one won’t work because the item(placeholder) was destroyed when the item before was put down. I hope you are following. I’m doing the same function in first person character blueprint for all items that I want to pickup and put down but as I said it works only once. Here is the putting down:


and here is the picking up.

The issue is in putting down when destroying “item” which is the placeholder under first person camera which works fine the first time, put when trying to pick up an object after that, it causes an error and the object is not placed in the placeholder because it was destroyed when dropping the previous object. How would I tweak this to use same method for picking up and putting down many items not only one??

1 Like

Instead of ‘destroy component’ why not also use ‘set static mesh’, but just set it to nothing? :slight_smile:

How would I set it to nothing? won’t that cause an error?

On the ‘set static mesh’ node, just leave the new mesh blank. It won’t give an error.

I would for starters replace the first branch, make array and for loop with just one ‘is valid’ exec check on the hit actor.

I don’t know what this ‘interact fun’ function is, but if it’s just to find the static mesh, you might as well just drag the hit component from the break hit result and check if it is a static mesh, if it is ,set the item’s static mesh to that component, and if it is not then cancel.

As clcokwork said, in the putting down code, you should replace destroy component with set static mesh to set it to blank.

And at the end there instead of getting all actors of class tray, shouldn’t you just be feeding it the hit actor?