To avoid the issue of the pickup being equipped no matter how far it is from the Player, what if instead of having HandleRaycast(PlayerController callingController) in WeaponPickup.cs call the Pickup() function, it simply calls the Mover component of the callingController? Then, you just let the OnTriggerEnter() do its thing and call the Pickup() function when the player enters the trigger radius. To make this work, you also have to include using using RPG.Movement; in WeaponPickup.cs which may not be very elegant from a dependency perspective.
That said, this is exactly what I did and now the player moves to the pickup before equipping it which feels more natural. My implementation changes:
public bool HandleRaycast(PlayerController callingController)
{
if (Input.GetMouseButtonDown(0))
{
Pickup(callingController.GetComponent());
}
return true;
}
to:
public bool HandleRaycast(PlayerController callingController)
{
if (Input.GetMouseButtonDown(0))
{
callingController.GetComponent<Mover>().StartMoveAction(transform.position, 1f);
}
return true;
}
Anyone see any issues with this approach from a dependency or other perspective?