I am using a raycast system to detect items in the world, and if the raycast detects an apple and I press "E" my character should pick up that specific apple. Same goes with any other objects that would be pickable.
I can't figure out a way of doing this neatly besides hard coding every single item with an "IF" statement to check if that specific item was targeted.
I have my thought on Comparing Tags but I don't see how I wouldn't have to hard code everything nontheless.
void Fire()
{
if (Physics.Raycast(transform.position, transform.forward, out hit, rayRange))
{
// If (Raycast hit enemy) Damage Enemy Accordingly based on weapon damage.
// If (Raycast hit Apple) Pick up apple.
// If (Raycast hit Drink) Pick up drink.
Destroy(hit.transform.gameObject); // Debug Only
Debug.Log(hit.transform.name); // Debug Only
}
nextFire = Time.time + fireRate; // Don't mind this.
}