How to switch between items

Item Switch Manager

This script controls the item switching system of the characters. It is possible to switch items by scrolling the mouse, sequentially with numbers on the alphanumeric keyboard, and by pressing the next/previous button.

How to use Sequential Item Switching

The item switching sequence is set in the Sequence Slot in the Inventory Component. You can drag and drop items into each slot and it will work normally.

Or you can use Slots in the UI to set items in sequence:

It is important to note that unlike Sequential Item Switching, the item switching order is in the order of position in the Hierarchy(inside player bone hand) by default.

Mobile Item Switching

Item Switching on mobile is done by Mobile Rig

Inventory Item Switching

It is possible to equip items from the inventory by pressing the item slot and then the equip button.

Switching by code

To switching an item for a code is simple, the below example code checks when you press the G key and switch items to the next one.

using UnityEngine;
public class SwitchOnPressGKeyExample : MonoBehaviour
{
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G)) 
        {
            ItemSwitchManager.NextPlayerItem();
        }
    }
}

Some static methods you can use in code for item switching:

Static Methods Description

SwitchCharacterItem(JUCharacterController character, int SwitchID)

Switch a JU Character item to a specific one in the list

SwitchPlayerItem(int SwitchID)

Switch player(JUCharacter with "Player" tag) item to a specific one in the list

NextPlayerItem()

Switch player(JUCharacter with "Player" tag) to next item in sequence.

PreviousPlayerItem()

Switch player(JUCharacter with "Player" tag) to previous item in sequence.

Last updated