hello every after creating this script i found a bug its when i switch back from key 2 to 1 key 1 one of the weapon donot work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class switchweopen : MonoBehaviour
{
public GameObject shotgun;
public GameObject ak47;
void Start()
{
shotgun.SetActive(false);
}
void Update()
{
if (Input.GetKey(KeyCode.Alpha1))
{
ak47.SetActive(true);
shotgun.SetActive(false);
}
if (Input.GetKey(KeyCode.Alpha2))
{
ak47.SetActive(false);
shotgun.SetActive(true);
}
}
}