Jump to content

How to add hats to a mob?


Recommended Posts

So I'm trying to add the ability to give Glommer a hat. I think I've already figured out how to add the recognition for the hat and stuff to actually be accepted and equipped:

local function ShouldAcceptItem(inst, item)
    return
        (   --accept all hats!
            item.components.equippable ~= nil and
            item.components.equippable.equipslot == EQUIPSLOTS.HEAD
        )
end

local function OnGetItemFromPlayer(inst, giver, item)
    --I wear hats
    if item.components.equippable ~= nil and item.components.equippable.equipslot == EQUIPSLOTS.HEAD then
        local current = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
        if current ~= nil then
            inst.components.inventory:DropItem(current)
        end
        inst.components.inventory:Equip(item)
        inst.AnimState:Show("hat")
    end
end

and then add this to the fn()

inst:AddComponent("inventory")

How would I edit the spriter file so that Glommer actually puts on the hat when I give it to him? And is there anything else I'm missing?

Link to comment
Share on other sites

If I replaced glommer’s animation rig with a new one through the mod, then used PrefabPostInit to add the hat code to glommer, would it work the same as if I had created a new custom glommer? Additionally, are there any tutorials on how to add/create an animation state in an animation rig?

Link to comment
Share on other sites

It would not be the same, but either way is fine. If you want to make all Glommers wear hats, also for the other players, then you have to make a server mod, which replaces the animation rig. I have no idea how to create those, but you can give Glommer any animation bank and build you want. I'm guessing you have to make a new animation bank for Glommer, which includes a hat-node or whatever.

There are no up-to-date tutorials. You can only follow the tutorials on the forums as best you can, and then go search these forums for solutions to the remaining problems you might have. There are many, many people who have been through here, who've used the same tutorials and asked the questions you have before. Take a look at my newcomer post for how to search the forum optimally, and general good advice about debugging and basics.

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