JU TPS Documentation
  • 🤩Welcome to JU TPS
  • 😄Quick Start
    • How to start a new scene
    • How to create a JU Character / Reskin Default Character / Setup New Characters
      • Ragdoll
      • Damageable Body
      • Physical Damage
      • Body Leaning Setup
      • Taking Damage / Healing
      • Footstep System
      • Resizable Capsule Collider
    • 📦 Addon Installer
  • 🎮Game Development
    • Game Styles
      • Third Person Shooter Style
      • First Person Shooter Style
      • Top Down Style
      • 2.5D Sidescroller Style
      • ⚠️Important Info About Cross-Plataform
    • Controls / Inputs
      • JU Input Manager
      • Input Events
    • How to create a Mobile Game with JU TPS
      • Mobile Inputs
    • How to load scene
      • Scene Controller
    • How to use Cover System
    • How to use inventory and add items
      • Inventory in UI
      • How to switch between items
      • How to align weapon rotation
    • How to create weapons and items
      • Prevent gun clipping through walls
      • Creating Projectiles/Bullets
    • How to use Dual Wielding System
    • How to use Armor/Cloth System
    • How to use Vehicle System
      • Standard Vehicle Configuration
      • How to create a Car Controller
      • How to create a Motorcycle Controller
      • Vehicle Engine Sounds
      • Coding Custom Wheeled Vehicles
      • How to enter and exit from a vehicle
    • How to use Gravity Switching
    • How to use Actions/Skill and Animation Events
      • JU TPS State Machine Behaviours
      • JUTPSActions Lib Scripting Reference
    • Camera State Trigger
    • How to use Enemies AI
    • How to use Vehicles AI
  • ⚙️Tools, Utils and Tutorials
    • General Tutorials
      • How to do Ragdoll Fall with Input Event
      • How to disable FPS Aim Mode / Scope / Iron Sight Aim
    • Auto Scripts
    • Icon Generator Tool
    • Destructible Objects System
      • Fracture Generator Tool
    • Pixel Quality Scaler
    • Camera Shake
    • Slow Motion
    • Gizmo Drawer
  • ▶️Video Tutorials
    • How to use JU TPS
  • 💬Discord Community
  • ❓Support | Help
  • 📍Roadmap
  • 🔃Change Log
  • 📦Official Addons
Powered by GitBook
On this page
  • Item Switch Manager
  • How to use Sequential Item Switching
  • Mobile Item Switching
  • Inventory Item Switching
  • Switching by code
  1. Game Development
  2. How to use inventory and add items

How to switch between items

PreviousInventory in UINextHow to align weapon rotation

Last updated 2 years ago

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

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.

Item Switching on mobile is done by

🎮
Mobile Rig