- Home /
inventory system some help and guides please :)
i have bene suing unity alittle bit now, for 6 months time, and i have made a few little dodads and other fun little things :) so i have decided to try and make a little for fun RPG nothing bug or huge just to get the hang of the coding of such things what i want is: and inventory like you see in world of warcraft, lord of the rings online etc. what it should do is:
you pick up an item from a mob / chest / anything. by clicking it.
it transfers the item to your inventory if you have the space.
if not you cannot pick it up and gets an error message.
you rightclick the item in your inventory to equip it in your character page.
your uneuqip same process just vice versa
i have an okay understanding of how to code alittle bit im no expert!! far far from it! what i made this far is an inventory script, added it to the player.()this script does nothing yet. and i made an item script that is as follows: `public class item : MonoBehaviour {
public bool isEquipped = false;
public int itemId;
public int buyPrice;
public int sellPrice;
public GameObject itemVisual;
public Texture2D icon;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//shows and hides item when equipped and unequipped
if (isEquipped == true){
itemVisual.renderer.enabled = true;
}
else itemVisual.renderer.enabled = false;
///////////////////////////////////////////////////
}
}
is this first of all a viable approach? and secondly how do i make the inventory? i know i can use gui etc but the drawcalls are just horrible!! how do you go about making such a thing? any help is much apreaciated! best regards -Martin
This is more of a discussion question that should be posted on the forums. Using OnGUI won't give you any more draw calls than this approach, and would be easier. Constantly checking isEquipped in Update is inefficient; it should just be done once when needed.
and how would i do that? how do i make a "function" like that? that i can call?
Answer by CrossTyreck · Jun 27, 2012 at 08:40 PM
Your starting nice. One thing I did was created another camera to handle your GUI texture (Inventory) and have those textures render when an item is in the inventory or not. When the item is in your inventory its the corresponding 3D objects renderer is off. When the item is equipped, its no longer in your inventory so the image is off but the renderer is turned on. Hope that helps a little.
Your answer
Follow this Question
Related Questions
How To Make A Numeric Inventory System? 0 Answers
Unity C# - Foreach loop - Inventory slot only changes quantity for the last child of an object 1 Answer
Is there a way to use the prefab image unity shows? 0 Answers
Help with GUILayout and tooltip(C#) 1 Answer
scroll bar inventory with slot count for equip items 0 Answers