as you see and sorry for my bad english.
there are too many helmets displayed but there is 1 on the place.
[123715-screenshot-20180901020348.png*_|123715]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCheck : MonoBehaviour {
public GameObject[] nearbyitems;
public GameObject[] listparentchildsobj;
public Transform listparent;
public GameObject objprefab;
public Item[] items;
public GameObject playerpanel;
void Start () {
}
void Update () {
listparentchildsobj = new GameObject[listparent.childCount];
for (int i = 0; i < listparent.childCount; i++)
{
listparentchildsobj *= listparent.GetChild(i).gameObject;*
}
if (nearbyitems.Length == 0)
{
for (int i = 0; i < listparentchildsobj.Length; i++)
{
Destroy(listparentchildsobj*.gameObject);*
}
items = new Item[0];
}
if (nearbyitems.Length > 0)
{
items = new Item[nearbyitems.Length];
for (int i = 0; i < nearbyitems.Length; i++)
{
items = nearbyitems*.GetComponent();*
}
}
if (Input.GetKeyDown(KeyCode.Tab))
{
playerpanel.transform.gameObject.SetActive(!playerpanel.activeInHierarchy);
}
for (int i = 0; i < items.Length; i++)
{
GameObject prefab = Instantiate(objprefab, listparent); //here
prefab.GetComponent().Set(items*.weapon);*
}
}
}
_*