Making a drop item from enemy

I have 1 enemy(for now) but i want to make him a drop sword (or an item) when it dies. I have this code by far but its kinda different(i used it for a chest where when you open it you can pick up some items!).

This is the one called(TreasureChest):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TreasureChest : Interactable {

	Animator animator;

	bool isOpen;
	public Item[] items;

	void Start() {
		animator = GetComponent<Animator> ();

	public override void Interact ()
		base.Interact ();
		if (!isOpen) {
			animator.SetTrigger ("Open");
			StartCoroutine (CollectTreasure ());

	IEnumerator CollectTreasure() {

		isOpen = true;

		yield return new WaitForSeconds (1f);
		print ("Chest opened");
		foreach (Item i in items) {
			Inventory.instance.Add (i);

This is called(Interactable):

using UnityEngine;
using UnityEngine.AI;

	This component is for all objects that the player can
	interact with such as enemies, items etc. It is meant
	to be used as a base class.

public class Interactable : MonoBehaviour {

	public float radius = 3f;
	public Transform interactionTransform;

	bool isFocus = false;	// Is this interactable currently being focused?
	Transform player;		// Reference to the player transform

	bool hasInteracted = false;	// Have we already interacted with the object?

	void Update ()
		if (isFocus)	// If currently being focused
			float distance = Vector3.Distance(player.position, interactionTransform.position);
			// If we haven't already interacted and the player is close enough
			if (!hasInteracted && distance <= radius)
				// Interact with the object
				hasInteracted = true;

	// Called when the object starts being focused
	public void OnFocused (Transform playerTransform)
		isFocus = true;
		hasInteracted = false;
		player = playerTransform;

	// Called when the object is no longer focused
	public void OnDefocused ()
		isFocus = false;
		hasInteracted = false;
		player = null;

	// This method is meant to be overwritten
	public virtual void Interact ()

	void OnDrawGizmosSelected ()
		Gizmos.color = Color.yellow;
		Gizmos.DrawWireSphere(interactionTransform.position, radius);


i want to turn one of the scripts to a boss drop item but i don’t know how help!!!

//add it to your enemy script
public GameObject drop;//your sword
private void OnDestroy() //called, when enemy will be destroyed
Instantiate(drop, transform.position, drop.transform.rotation); //your dropped sword

So what you can do is similar to Lord of the rings online system.

They spawn a treasure chest in every boss room on level load and they randomise the items and put them in the chest, I suppose it’s an array as they know the amount of items they want to put in. So they have the chest with it’s interaction logic, and the items inside. Once the boss is dead, the user is ALLOWED to interact with the chest, if the boss is alive they will unable to open the chest.

The interaction logic with the treasure chest itself should be pretty straight forward, it would hold an array of items if you know the amount, or in a list if the amount is unknown. Once the boss is dead, the treasure chest subscribes to the event and releases the “lock” so that the players are now able to open the chest. Player clicks on the chest and a window pops up with the contents of array, once the player clicks on an item it’s placed in their inventory array or list and then removed from the chest array.

To detect what the player is clicking on, like click on a chest you can use ray casting. Also please be careful about inheritance, as you are making a tightly coupled system. Favour composition over inheritance. Some more info here: Cowboy Programming » Evolve Your Hierarchy