Jump to content

Recommended Posts

Hello there!

I need a tiny bit of help about my custom character: I would like him to change his texture, while he's holding his custom item, and change it back to default, when he unequips it.

I've came up with the following coding, but it does nothing in the game (it does not crash though):

Spoiler

-- Tiger skin
    local function OnEquipCustom(inst, data)
        if data.item.prefab == "tigerpan" then
            inst.AnimState:SetBuild("thejanitiger")
        end
    end
    
    local function OnUnequipCustom(inst, data)
        if data.item.prefab == "tigerpan" then
            inst.AnimState:SetBuild("thejani")
        end
    end

I've put this into the character prefab's master postnit section. The "tigerpan" is the custom item, "thejanitiger" is the texture he should equip with the item (it has a full texture folder inside the export folder), and "thejani" is his default texture folder.

What do I do wrong?

Edited by BillTheCipher

Maybe include the anim assets to your prefab as well.

 

local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
    Asset("ANIM", "anim/name_of_file.zip"),
}

 

Edited by thomas4846

@thomas4846 Oof... I've totally forgot that. Thanks!

I added it to the assets, but the game doesn't compiles the textures into an anim ZIP for some reason.

Is there something else I'm missing out?

Edited by BillTheCipher

@thomas4846 When I run the autocomplier, it doesn't generate an anim ZIP file - neither into the "thejanitiger" export folder, neither into the anim folder.

This is the only two coding that currently contains "thejanitiger" (alias the equip skin):

Spoiler

local assets = {
    Asset("SCRIPT", "scripts/prefabs/player_common.lua"),
    Asset( "ANIM", "anim/thejanitiger.zip" ),
}

Spoiler

-- Tiger skin
    local function OnEquipCustom(inst, data)
        if data.item.prefab == "tigerpan" then
            inst.AnimState:SetBuild("thejanitiger")
        end
    end
    
    local function OnUnequipCustom(inst, data)
        if data.item.prefab == "tigerpan" then
            inst.AnimState:SetBuild("thejani")
        end
    end

Is there anywhere else I should reference the "thejanitiger" texture, or the problem is rooted in something else?

@thomas4846 I figured it out: I've accidently named the hair files to hair_hat.

Silly me :)

However, his texture still not changes when he equips his item :(

Edited by BillTheCipher
	inst:ListenForEvent("equip", function(inst, data)
		if data.item.prefab == "tigerpan" then
			inst.AnimState:SetBuild("thejanitiger")
		end
	end)
	
	inst:ListenForEvent("unequip", function(inst, data)
		if data.item.prefab == "tigerpan" then
			inst.AnimState:SetBuild("thejani")
		end
	end)

you forgot to call the functions

  • Like 1

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
×
  • Create New...