I am getting this error
When i am killing the enemy
ArgumentException: GetComponent requires that the requested component ‘Item’ derives from MonoBehaviour or Component or is an interface.
My Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/* This makes our enemy interactable. */
[RequireComponent(typeof(CharacterStats))]
public class Enemy : Interactable {
CharacterStats stats;
public RagdollManager ragdoll;
public GameObject Sword;//your sword
private void OnDestroy() //called, when enemy will be destroyed
{
Inventory.instance.Add(Sword.GetComponent<Item>());
}
void Start ()
{
stats = GetComponent<CharacterStats>();
stats.OnHealthReachedZero += Die;
}
// When we interact with the enemy: We attack it.
public override void Interact()
{
print ("Interact");
CharacterCombat combatManager = Player.instance.playerCombatManager;
combatManager.Attack(stats);
}
void Die() {
ragdoll.transform.parent = null;
ragdoll.Setup ();
Destroy (gameObject);
}
}
my inventory it static