ItemObject.cs scripts at runtime

JohnG

Member
Hi,

Let me start by telling you what I want to do (images first).

UCC Character in Hierarchy
runtimeitem.png

Inspector info of SKS gameobject above.
runtimeitem2.png
Screenshot 2021-01-18 141525.png

Question

So what I want is to find out what item (weapon) is active. So I can get the information on my script lefthandpos.cs. In this case gameobject SKS is active.

I am trying to solve this by looping through child objects of Items (M1911 and SKS + whatever else I pickup later), and was intending to use ItemObject.cs - IsEquipped(Bool), but I dont know how to get it (i have opened ItemObject.cs but dont see that variable there).

If you know of a better way for me to find the gameobject of the equipped item, please let me know.
 
Have you read the API examples on the documentation page?

aren't you simply looking for:
Code:
var item = m_InventorySystemBridge.GetActiveItem(0);
Where the item is a UCC Item and 0 is the slot index.

The docuementation shows you how to go from UCC Item to UIS Item and vice versa. Since UCC Item is a component, you shouldn't need to but if you want to get the ItemObject from the UIS Item you can.
 
@Sangemdoko Yes thanks, that is exactly what I need to solve my problem. And yes, looked at all docs, watched videos, its just hard to remember everything so you rely on searching docs, and in this case I was searching for "weapon equipped", rather than "weapon active".
 
Top