LovelyMOA Posted March 18, 2024 Share Posted March 18, 2024 (edited) Hi! I'm new and I wanted to create an account because I need help, I did a custom weapon, it works fine but it's invisible when I equip it and on the ground, someone knows how to fix it? :(( Also, sorry if my english is broken! And this is my first custom weapon so I don't know what it's the problem AAAA Here is the code if that helps! local Assets = { -- Animation files for the item (showing it on the ground and swap symbols for the players). Asset("ANIM", "anim/txtlightstick.zip"), Asset("ANIM", "anim/txtlightstick_ground.zip"), -- Inventory image and atlas file used for the item. Asset("ATLAS", "images/inventoryimages/txtlightstick.xml"), Asset("IMAGE", "images/inventoryimages/txtlightstick.tex"), } local function OnEquip(inst, owner) -- This will override symbol "swap_body" of the equipping player with your custom build symbol. -- Here's what this function is overriding: -- owner.AnimState:OverrideSymbol(Player's_symbol, Your_build(*.zip_filename), Symbol_from_your_build(name_of_subfolder_with_art) owner.AnimState:OverrideSymbol("swap_object", "txtlightstick", "swap_object") -- Players have 2 left arms - one of them is hidden when we are not holding an item and vice versa. -- Since we want to show an item on equip - hide ARM_normal and show ARM_carry. 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 function MainFunction() -- Functions which are performed both on Client and Server start here. local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) -- Add minimap icon. Remember about its XML in modmain.lua! local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon("txtlightstick.tex") --[[ ANIMSTATE ]]-- -- This is the name visible on the top of hierarchy in Spriter. inst.AnimState:SetBank("txtlightstick_ground") -- This is the name of your compiled*.zip file. inst.AnimState:SetBuild("txtlightstick_ground") -- This is the animation name while item is on the ground. inst.AnimState:PlayAnimation("anim") --[[ TAGS ]]-- inst:AddTag("txtlightstick") MakeInventoryFloatable(inst, "small", 0.05, {1.2, 0.75, 1.2}) inst.entity:SetPristine() if not TheWorld.ismastersim then -- If we're not the host - stop performing further functions. -- Only server functions below. return inst end inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "txtlightstick" inst.components.inventoryitem.atlasname = "images/inventoryimages/txtlightstick.xml" inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) inst:AddComponent("weapon") inst.components.weapon:SetDamage(44) MakeHauntableLaunch(inst) return inst end return Prefab("common/inventory/txtlightstick", MainFunction, Assets) Thank you for your time :(( Edited March 18, 2024 by LovelyMOA I forgot to put "custom" on the title 1 Link to comment https://forums.kleientertainment.com/forums/topic/155042-invisible-custom-weapon-when-equipped-and-on-the-ground/ Share on other sites More sharing options...
LovelyMOA Posted March 25, 2024 Author Share Posted March 25, 2024 Can a moderator delete or something this topic? I solved it! The name of the weapon on the spriter was wrong! Link to comment https://forums.kleientertainment.com/forums/topic/155042-invisible-custom-weapon-when-equipped-and-on-the-ground/#findComment-1707504 Share on other sites More sharing options...
DarkM Posted August 23, 2025 Share Posted August 23, 2025 Thanks!! Thanks to your code, I realized what the error was that was driving me crazy in mine Link to comment https://forums.kleientertainment.com/forums/topic/155042-invisible-custom-weapon-when-equipped-and-on-the-ground/#findComment-1832657 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now