First Post Speaks About Weapon Switching Here’s The Code! :-
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class WeaponSwicthScript : MonoBehaviour {
public List m_weapons = new List();
public int m_curWeapon = 0;
private int m_listMax;
private int m_listLeast;
void Start()
{
m_curWeapon = 1;
}
void Update ()
{
m_listLeast = 0 + 1;
m_listMax = m_weapons.Count - 1;
foreach(GameObject weapon in m_weapons)
{
weapon.SetActive(false);
m_weapons[m_curWeapon].SetActive(true);
}
if ( Input.GetKeyDown(KeyCode.Mouse0) && m_curWeapon < m_listMax )
{
m_curWeapon++;
}
// Previews
if ( Input.GetKeyDown(KeyCode.Mouse1) && m_curWeapon > m_listLeast )
{
m_curWeapon–;
}
}
}
Any Questions? In The Comments!