I need help with Pick Ups

I’m trying to make a feature that causes a pick up to be magnetized to the player when the player gets close enough. This would be to get rid of the annoyance of just missing the pickup by a slight amount, without having an unrealistically big hit box. How could I go about doing this?

Note: The game I’m making is programmed in C#.

Have you tried Vector3.Distance? You can change the scale of the object when the distance falls below a value. If you want an item to grow bigger as you get closer, you can use Vector3.Lerp as well.

@Jessespike might have missunterstood you but generally his solution would be correct:

check the players distance to all pickup-objects if the distance is smaller than X move the object a bit closer to the player (velocity can be calculated by distance (further away > slower distance)) if the distance is smaller than Y, pick it up.

to move the object closer to the player you can use Lerp, thats correct too.


instead of checking every single pickable every frame you could add a collider around the player (add it as a child gameobject). make it a trigger, set it to never sleep.

add a script to the pickables, where you use “OnTriggerStay”, to check if its in the “magnetsphere” and move it a bit closer.