Jump to content

Handslot item


Recommended Posts

Hello!
Theres my problem: i just dont know now to rise item on chracter's hand. I drew a sword for my character, but if i'll try to make texture bigger \because I want the blade at head level\ character it does not rise higher
image.png.60168a0a57cae84407e94bdc2e6860d0.png  its hurts, i think! 
Sword's image is 200x200
Theres sword.lua:
 

Quote

local assets=

    Asset("ANIM", "anim/sword.zip"),
    Asset("ANIM", "anim/swap_sword.zip"), 

    Asset("ATLAS", "images/inventoryimages/sword.xml"),
    Asset("IMAGE", "images/inventoryimages/sword.tex"),
}

local prefabs = 
{
}

local function fn(colour)

    local function OnEquip(inst, owner) 
        owner.AnimState:OverrideSymbol("swap_object", "swap_sword", "sword")
        owner.AnimState:Show("ARM_carry") 
        owner.AnimState:Hide("ARM_normal") 
    end

    local function OnUnequip(inst, owner) 
        owner.AnimState:Hide("ARM_carry") 
        owner.AnimState:Show("ARM_normal") 
    end
    

    
    local inst = CreateEntity()
    local trans = inst.entity:AddTransform()
    local anim = inst.entity:AddAnimState()
    
    if not TheWorld.ismastersim then
      
    return inst
      
    end
    
        inst:AddComponent("weapon")
    inst.components.weapon:SetDamage(40)
    
        inst:AddComponent("inspectable")
        
    anim:SetBank("sword")
    anim:SetBuild("sword")
    anim:PlayAnimation("idle")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "sword"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/sword.xml"
    
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
   
end

return  Prefab("common/inventory/sword", fn, assets, prefabs)

I will be glad to any answers!

Edited by Inutile Vie
Link to comment
Share on other sites

In spriter change the pivot position to the handle. You need to change it in folder symbol.

You can either do this via text editor to change the folder symbol pivot or in spritet when you click on the texture in the folder you can change the default pivot.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...