public class Mine : MonoBehaviour
{
[SerializeField] int health = 35;
[SerializeField] ItemObject yield;
[SerializeField] int amount;
public void Mining(int strength)
{
if (health-strength > 0)
{
health -= strength;
}
else
{
Destroy(gameObject);
}
}
public void OnDestroy()
{
for (int i = 0; i < yield.Length; i++)
{
Pickup pickup = Instantiate(PrefabsRef.prefabs.Pickup, transform.position, Quaternion.identity).GetComponent<Pickup>();
pickup.ThrowAway(yield_, amount*);*_
}
}
}
Simple issue really, I have one class that handles all my pickups, so whenever I want to drop multiple stacks of items I just instantiate it multiple times using for loop.
As you see above my current implementation is not perfect and prone to errors as the two arrays are not synced. I have to set up items and the amounts seperately and I would prefer to set amount per each item entry.
Is there an easy way of doing it better or connecting those two arrays at least in the inspector ?