Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Inventory = How to add items :) C-Sharp

$
0
0
Hi, im trying to create an inventory system to my game. But i have problem with add items to my inventory. it is sad for me :( I've got: In inventory.cs: float[,] plecak = new float[4,4]; // tablica, there are polish so ;) there is a two-dimensional array = plecak. and simple GUI slots for(int i = 0; i < 4; i++) { for(int k = 0; k < 4; k++) { GUI.BeginGroup(new Rect(12,15,300,300)); GUI.Box (new Rect(5+(i*42),5+(k*42),40,40),":" +plecak[k,i]); GUI.EndGroup(); } } On Item.cs i've go: private GameObject Gracz; private float odleglosc; public Texture2D ikona; void Start() { Gracz = GameObject.FindWithTag("Player"); } void Update() { } void OnMouseDown() { odleglosc = (transform.position - Gracz.transform.position).sqrMagnitude; if(odleglosc <= 4f) { print("Jestes blisko."); //Here!!!! Destroy(gameObject); } } Item on the ground have Tag = Item. And, there where is "//Here!!!" i need some code to pick up items :( could u help me? Please?

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>