Item Switch System
Item Switch Input Configuration
The Item Switch system is controlled by the JU Character Controller and JU Inventory, they use the Player Character Inputs Asset file to call the item switch functions.
Here you can configure how you want your game's item exchange functions to be called:

How to use Slot/Sequential Item Switching
Sequential Item switching is seen in many shooting games where you have a primary, secondary, tertiary weapon... it is possible to have this mechanic using the Sequential Item Switch system.
The item switching sequence is set in the Sequence Slot in the JU Inventory script.
You can drag and drop items into each slot to set the default sequence.

How to use UI Slot to set Sequential Switch order
You can use UI Inventory Slots to set primary, secondary, tertiary weapons...
You can also configure the Inventory Slot UI to only accept certain tag types, for example only accept large weapons as primary weapons and small weapons as secondary weapons.

UI Slot Item Switching
If you activate the highlighted option below, you will activate a panel with options to use in the Inventory Slots.


Item Switching by code
To swtich items with a code is simple, the example code below switches items with a timer.
using UnityEngine;
using JUTPS; // <-- Use JUTPS Lib
public class SwitchItemByScriptSample : MonoBehaviour
{
public float SecondsToSwitchItem = 2;
public JUCharacterController JUCharacter;
void Start()
{
// >>> Call the function at the given time repeatedly
InvokeRepeating(nameof(SwitchToNextItem), SecondsToSwitchItem, SecondsToSwitchItem);
}
private void SwitchToNextItem()
{
// >>> Call Next Item Switch function by JUCharacterController
JUCharacter.SwitchToNextItem();
}
}
Switching Methods:
// >>> Call next item
JUCharacter.SwitchToNextItem();
// >>> Call previous item
JUCharacter.SwitchToPreviousItem();
// >>> Switch to specific item in right hand
JUCharacter.SwitchToItem(id: 2, RightHand: true);
// >>> Switch to sequential slot item
JUCharacter.SwitchToItemInSequentialSlot(JUTPS.InventorySystem.JUInventory.SequentialSlotsEnum.third);
Last updated