I’m making a backrooms game and a common request is that I make a script that allows the player to pick up items. I do not know how to do this, and I require assistance from a more experienced programmer than I am. Please help asap.
There is a number of picking tutorials and examples in this page:
Thanks, that could be useful in the future, but I need something, preferably a script, that allows the player to pick up items. There does not need to be a inventory feature, I just need something that will allow an item to be “picked up,” meaning just held in front of the player, and traveling along with them.
Hi @slatherycproductions! Maybe my drag and drop example project can help you.
Thank you so much!! That’s perfect. One thing though, is there a way to reduce the range?
Yes, you can limit the raycast distance (for this you need to change the current way of raycasting) or check the distance before picking up (probably the easiest to do).
Probably going to go with a distance checker, how would I do this?
An easy way to check when you are in proximity to pick up and item is to use colliders and triggers:
As soon as you picked it you can add it as a child to your player, to get it to follow you.
Okay, I implemented the picking script into the game, but it cannot read properties of screentoworld, so Im getting an error
Probably because you didn’t attach the script on the camera entity.
ah, yes, it works now. Still haven’t figured out range, could you send me the code that changes range?
I have updated my example project.