void OnTriggerStay2D(Collider2D collision) { IStationaryObjectUse usableObject = collision.GetComponent <IStationaryObjectUse>(); if (usableObject != null && Input.GetKeyDown(KeyCode.F)) { usableObject.Use(); } PickableObject pickedObject = collision.GetComponent <PickableObject>(); if (pickedObject != null && Input.GetKeyDown(KeyCode.F)) { DropObject(); pickedObject.Pickup(); objectInHand = pickedObject; AttachObjectToHand(collision.transform); } }
public void PickupObject(string objectName) { switch (objectName) { case "Keys": keys.Pickup(); break; case "Wallet": wallet.Pickup(); break; case "Phone": phone.Pickup(); break; default: break; } }