Here’s my script:
using UnityEngine;
using System.Collections;
public class ItemPickup : MonoBehaviour {
public AudioClip pickupSound;
// Use this for initialization
void Start () {
StartCoroutine (DespawnTimer ());
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(other.tag == "Player")
{
if(gameObject.tag == "Item")
{
Inventory inventory = GameObject.Find("Inventory").GetComponent<Inventory>();
if(this.gameObject.name.Equals("Wood"))
{
audio.PlayOneShot(pickupSound);
Network.Destroy(gameObject,pickupSound.length);
inventory.AddItem("Wood");
}
}
}
}
IEnumerator DespawnTimer()
{
yield return new WaitForSeconds (120);
Destroy (gameObject);
}
}
If i delete network from network.destroy the error gone but i need network.destroy but cannot figure out what is wrong with this script ://