I can only pick up items in reverse order I placed them

Hey there!

I am currently creating a little game in order to get into Unreal Engine. It’s similar to the old Slender game. Basically the player has to pick up 8 dollar bills. With the help of many tutorials (and a lot of trial and error) I managed to set up a simple Item and Score system. When the player is in the collision area of the dollar bill and presses E, the item will get destroyed and the player gets a point. This works fine so far.

However, when I place the dollar bills around the map I can only pick them up in a specific order. I have to pick up the one I placed down last first, and then work my way through to the one I placed first. I want the player to be able to pick up the bills in whatever order they find them though. Does anyone have any idea where I made a mistake? Also sorry if this is something obvious, I am still new to this! ^^"

Have a nice day!

I think it’s because you’re calling enable input on begin play. Try to move it to after the cast to FPC succeeds.

This logic makes little sense. The script should not be in the pickup class - this script belongs in the Pawn or Player Controller. At the moment every actor is duplicating the code unnecessarily and lets actors handle input which complicates things event further.


Instead, do it in the Pawn (which already can handle input) - the First Person Character in your case; add a sphere to the player and check for overlaps there.

Thanks for the reply! I have a question. When I put the pickup Script into FirstPersonCharacter, how do I get the target for the destroy actor node? So basically how can I make the reference to the Dollarbill Actor?

Here’s one way to do it:

The character has a sphere with a radius big enough to envelop nearby objects. When the player presses E, you check for actors that are around. This returns ALL of them, so you can scoop more than one pickup at a time. If you want to pick up one only, Get[0] instead of Loop.

edit: if you want to just destroy it, there’s no need to cast. It may also be a good idea to check the length of that array before you attempt to destroy something that does not exist - as in, no objects were found around.

Thanks a bunch! I got it to work now thanks to you :slight_smile: Have a wonderful day!