# \[Old Versions] 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.

<div align="left"><figure><img src="/files/dTPG5WXPLEWgIj5WLdEW" alt=""><figcaption></figcaption></figure></div>

## 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.

<div align="left"><figure><img src="/files/Uo1McxGf6HlhFv4F9R3A" alt=""><figcaption></figcaption></figure></div>

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

<div align="left"><figure><img src="/files/49FzCpU8x4Ib7SC68r77" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
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.
{% endhint %}

## Mobile Item Switching

Item Switching on mobile is done by [Mobile Rig](/ju-tps-documentation/game-development/how-to-create-a-mobile-game-with-ju-tps/mobile-inputs.md)&#x20;

<figure><img src="/files/NxWHlqjzZhpJlC9N0GkK" alt=""><figcaption></figcaption></figure>

## Inventory Item Switching

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

<div align="left"><figure><img src="/files/Jd2QzYvmquodyJj3Pi8Z" alt=""><figcaption></figcaption></figure></div>

## 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.

{% code lineNumbers="true" %}

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

{% endcode %}

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

| Static Methods                                                                                                                       | Description                                                                     |
| ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------- |
| SwitchCharacterItem(<mark style="color:blue;">JUCharacterController</mark> character, <mark style="color:blue;">int</mark> SwitchID) | Switch a JU Character item to a specific one in the list                        |
| SwitchPlayerItem(<mark style="color:blue;">int</mark> 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.      |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julhiecio.gitbook.io/ju-tps-documentation/game-development/how-to-use-inventory-and-add-items/old-versions-how-to-switch-between-items.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
