I am making a simple inventory that has a max of like 3 things and can change out items for other ones. I need the item you pick up to change with the item you are holding.
heres what i have so far
using UnityEngine;
using System.Collections;
public class MoneyManager : MonoBehaviour
{
public int money = 500;
public GameObject AR15;
void OnGUI()
{
GUI.Label (new Rect (0,0,80,20), money.ToString(), "box");
}
void Update()
{
Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 3))
{
//print("Hit "+hit.collider.name);
if (hit.collider.tag == "Jug")
{
print("Hit "+hit.collider.name);
if(Input.GetKeyDown(KeyCode.E) && money >= 2000)
{
money -= 2000;
hit.collider.gameObject.SendMessage("spawn", SendMessageOptions.DontRequireReceiver);
}
}
//picking up a gun here
if (hit.collider.tag == "ar15")
{
print("Hit "+hit.collider.name);
if(Input.GetKeyDown(KeyCode.E) && money >= 1500)
{
money -= 1500;
}
}
}
}
}
i sorta got stuck on the inventory thing cant think of how to do it