Quantcast
Channel: Questions in topic: "loops"
Viewing all articles
Browse latest Browse all 184

Inventory System Help

$
0
0
Hi, I'm making a RPG-like game, and I'd like some help on what's going wrong on my inventory system. Right now, it kind of works. What I mean is sometimes it will work fine, but other times it won't at all. Basically, sometimes when I click the pickup item it registers and goes into the inventory, and it fills the spot and checks the boolean. But sometimes it requires both items in the hierarchy to be active for the boolean to be true. Here is the inventory space code: #pragma strict var isEmpty : boolean; var items : GameObject[]; function Update () { for(var i = 0; i < items.Length; i++) { if(items[i].activeInHierarchy) { break; isEmpty = false; } else { isEmpty = true; } return; } } And the item pickup code: #pragma strict var inventorySpace : InventorySpace[]; var objs : GameObject[]; function OnMouseDown () { for(var i = 0; i < inventorySpace.Length; i++) { if(inventorySpace[i].isEmpty) { objs[i].active = true; inventorySpace[i].isEmpty = false; break; } } } Any help would be greatly appreciated!

Viewing all articles
Browse latest Browse all 184

Trending Articles



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