How do you properly switch equipment?

Ziron999

New member
I've been trying to many different ways but every way ends up being extremely buggy. here is my current idea:
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Opsive.UltimateCharacterController.Inventory;
using Opsive.UltimateCharacterController.Events;
using Opsive.UltimateCharacterController.Character.Abilities.Items;
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
using Devdog;
using Devdog.InventoryPro;
using Devdog.General;

public class BridgeTest : MonoBehaviour
{
    //public SkillbarUI SkillBarUI;

    GameObject Player;
    ItemType currentItemType;
    Inventory inv;
    //EquipUnequip eu = new EquipUnequip();
    ItemType bowType;
    public ItemPickup[] initalizePickup;
    //ItemSetManager ism;
    //List<ItemSet> cis;
    //ItemType prevItemType;
    // Start is called before the first frame update
    void Start()
    {
        Player = PlayerManager.instance.currentPlayer.gameObject;
        inv = Player.GetComponent<Inventory>();
        //ism = Player.GetComponent<ItemSetManager>();
        //eu = Player.GetComponent<EquipUnequip>();
        bowType = inv.DefaultLoadout[2].ItemType;
        //for (int i = 0; i < initalizePickup.Length; i++)
        //{
            //initalizePickup[i].TriggerEnter(Player);
        //}
        //ism = Player.GetComponent<ItemSetManager>();
        //cis = ism.CategoryItemSets[0].ItemSetList;
        //prevItemType = cis[7].Slots[0];
    }
    //0=body
    //1=knife
    //2=bow
    //3=bowarrow
    //4=sword
    //5=pistol
    //6=pistolbullet
    //7=assaultrifle
    //8=assaultriflebullet
    //9=shield
    //10=shotgun
    //11=shotgunbullet
    //12=katana
    //13=sniperrifle
    //14=sniperriflebullet
    //15=rocketlauncher
    //16=rocket

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            currentItemType = inv.DefaultLoadout[0].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
            inv.UseItem(currentItemType, 1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            currentItemType = inv.DefaultLoadout[1].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
            inv.UseItem(currentItemType, 1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            //slot 1 is bugged for force equip
            currentItemType = inv.DefaultLoadout[2].ItemType;
            inv.PickupItemType(currentItemType, 1, 1, true, true);
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            currentItemType = inv.DefaultLoadout[3].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
        }
        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            currentItemType = inv.DefaultLoadout[4].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
            inv.UseItem(currentItemType, 1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            //slot 1 is bugged for force equip
            currentItemType = inv.DefaultLoadout[5].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
        }
        if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            currentItemType = inv.DefaultLoadout[6].ItemType;
            inv.PickupItemType(currentItemType, 1, 1, true, true);
            inv.UseItem(currentItemType, 1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            currentItemType = inv.DefaultLoadout[7].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
            inv.UseItem(currentItemType, 1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha9))
        {
            currentItemType = inv.DefaultLoadout[8].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
            inv.UseItem(currentItemType, 1);
        }
        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            currentItemType = inv.DefaultLoadout[9].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
            inv.UseItem(currentItemType, 1);
        }
        if (Input.GetKeyDown(KeyCode.Minus))
        {
            currentItemType = inv.DefaultLoadout[10].ItemType;
            inv.PickupItemType(currentItemType, 1, 0, true, true);
            inv.UseItem(currentItemType, 1);
        }
    }
}
What is the best way to do this?
 
Last edited:
Top