Jump to content

item that transforms the character while held


Recommended Posts

I made an item that changes the character while equipped, but i can't figure out how to change it back to the original character.  On the OnEquip function I use "owner.AnimState:SetBuild" which works fine, but I don't know what to add to the OnUnequip function to change it back to the original build.  If I could get the name of the character, I could set the build back to that, but I couldn't find any code that does that.  Closest I found was printing "ThePlayer" show and id and name of your character but couldn't figure out how to get just the character name.

 

Link to comment
Share on other sites

Thanks! this makes my code look so much cleaner.  I have one more question.  If I load a game while the item is equipped, it shows the character image instead of the new one.  I tried to fix it with an OnLoad function but having an issue

local function onload(inst, owner)

    print("loaded")
    if inst.components.equippable:IsEquipped() then
    
        owner.AnimState:SetBuild("wilton")
    end
end

The onload function is getting called since it's printing "loaded" to the console but the "if inst.components.equippable:IsEquipped()" isn't returning true.  Maybe it's not considered equipped until after the onload function is called?

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...