Beispiel #1
0
    IEnumerator ChangeItem(GameObject _newItem)
    {
        if (item != null)
        {
            item.SetPosition(-2.0f * Vector3.up);
            item.CancelActivation();
            SoundManager.instance.StopSound(item.source);
            yield return(new WaitForSeconds(0.2f));

            Destroy(item.gameObject);
            item = null;
        }
        if (_newItem != null)
        {
            if (DataManager.instance.isMulti)
            {
                if (!isServer)
                {
                    yield break;
                }
                item = Instantiate(_newItem, transform).GetComponent <Interactible>();
                NetworkServer.Spawn(item.gameObject);
                RpcChangeItem(item.gameObject, gameObject);
            }
            else
            {
                item = Instantiate(_newItem, transform).GetComponent <Interactible>();
                item.gameObject.SetActive(true);
                item.transform.localPosition = -2.0f * Vector3.up;
                item.SetPosition(Vector3.zero);
            }
        }
    }