Hey guys, So im getting the error in the title.
I’m trying to create a numeric inventory system(for keys 1,2,3,4 and 5).
Here is my code.
using UnityEngine;
using System.Collections;
public class playerInventory : MonoBehaviour {
public int currentWeapon;
public GameObject[] weapons;
public int selected = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
loopThroughBackpack ();
}
void loopThroughBackpack(){
if (Input.GetKeyDown (KeyCode.Alpha1)) {
selected = 0;
Debug.Log (weapons[selected]);
}
else if(Input.GetKeyDown(KeyCode.Alpha2)){
selected = 1;
Debug.Log(weapons[selected]);
Instantiate (weapons[selected], weapons[selected].transform.parent.position, transform.rotation );
}
}
}
What im trying to do is spawn a asset called canteen and then parent it to the First person controller’s Main Camera.
Any help is really appreciated!