using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; using UnityEngine; public class item : MonoBehaviour { public bool inBox = true; public GameObject target; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void pick() { if (inBox) { transform.SetParent(GameObject.Find("Bag").transform); inBox = false; } else { if(Camera.main.GetComponent().inTarget) { int i = target.GetComponent().i; if(i<= target.transform.childCount) { target.transform.GetChild(i).gameObject.SetActive(true); target.GetComponent().i=i+1; gameObject.SetActive(false); } } } } }