[RPG Core] pickup immedialty with new raycast implementation

I am following RPG core combat course and I noticed a strange behavior with pickups.
I’m close to the end (last chapter : Character stats, Spawning damage text).

We have recently implemented improved Raycast system and know, when I click on a pickup item, I pickup immediatly even if I’m very far from it.
Before improved Raycast system, we were using pickup collider to pickup an object.

I’m wondering if I forgot something when following lessons or it’s the same for everyone ?
In this, will this problem be solved before the end of this course ?

thanks for infos

It’s not solved directly in the course, though we’ve given you the building blocks to solve it…

Here’s the broad outline of my solution:

First, I have a Component called Collector which implements the IAction interface.

The Collector’s StartCollectionAction(Pickup pickup) sets a Pickup target, just like the Fighter component

The Collector’s Update uses basically the same logic as the Fighter’s Update… if there is a target, then check the distance, if it’s out of range, GetComponent().MoveTo(target.transform.position);

If it’s within range, pickup the item.

In the Pickup’s HandleRayCast, call the Collector’s StartCollectionAction() instead of picking up the pickup.

thanks for your answer !
I will continue to follow lessons for now (to avoid to have too differences with Sam) and, then, I will use your comments to modify my project :slight_smile: