doraexplora Posted August 14, 2024 Share Posted August 14, 2024 This is the code for my weapon: local assets = { Asset("ANIM", "anim/stick.zip"), Asset("ANIM", "anim/swap_stick.zip"), } local prefabs = { } local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_stick", "swap_stick") 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 thingory() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) inst.AnimState:SetBank("stick") inst.AnimState:SetBuild("stick") inst.AnimState:PlayAnimation("idle") inst.AnimState:SetBank("swap_stick") inst.AnimState:SetBuild("swap_stick") inst.AnimState:PlayAnimation("idle") inst:AddTag("sticky") MakeInventoryFloatable(inst, "small", 0.05, {1.2, 0.75, 1.2}) inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "stick" inst.components.inventoryitem.atlasname = "images/inventoryimages/stick.xml" inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) inst:AddComponent("inspectable") inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(40) --- Durability inst.components.finiteuses:SetUses(40) inst.components.finiteuses:SetOnFinished(inst.Remove) inst:AddComponent("weapon") inst.components.weapon:SetDamage(34) ---Damage MakeHauntableLaunch(inst) return inst end return Prefab("stick", thingory, assets, prefabs) Link to comment https://forums.kleientertainment.com/forums/topic/159037-custom-weapon-is-invisible-when-equipped-in-hand/ Share on other sites More sharing options...
heavemnoon0107 Posted September 27, 2024 Share Posted September 27, 2024 Based on your: Asset("ANIM", "anim/stick.zip"), Asset("ANIM", "anim/swap_stick.zip"), I infer that you've separated the folders for "on the ground" and "in hand" and created two different scml files. The main control for displaying the item in hand is: owner.AnimState:OverrideSymbol("swap_object", "swap_stick", "swap_stick") The last three parameters represent ("replacement position", "build name (in your case, it's definitely "swap_stick")", ("the folder where the image to be displayed under this build is located"). Please ensure that the folder name is indeed "swap_stick". In the swap_stick scml, name the animation in the bottom right corner as "BUILD". The following: inst.AnimState:SetBank("stick") inst.AnimState:SetBuild("stick") inst.AnimState:PlayAnimation("idle") inst.AnimState:SetBank("swap_stick") inst.AnimState:SetBuild("swap_stick") inst.AnimState:PlayAnimation("idle") The bottom three lines are unnecessary and can be removed. The swapping is directly handled by owner.AnimState:OverrideSymbol("swap_object", "swap_stick", "swap_stick"). Just keep the top part, which is used to display the animation when the item is on the ground. Please ensure that the bank name "stick" and the animation name "idle" in the bottom right corner of your scml match your code. Link to comment https://forums.kleientertainment.com/forums/topic/159037-custom-weapon-is-invisible-when-equipped-in-hand/#findComment-1750936 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