KXWl1 Posted December 27, 2021 Share Posted December 27, 2021 I have a new problem, that is, changing the skin of pets. Here is the code: if target:HasTag("critter") then local fx = SpawnPrefab("reskin_tool_fx") local fx_info = reskin_fx_info[target.prefab] or {} local scale_override = fx_info.scale or 1 fx.Transform:SetScale(scale_override, scale_override, scale_override) local fx_pos_x, fx_pos_y, fx_pos_z = target.Transform:GetWorldPosition() fx_pos_y = fx_pos_y + (fx_info.offset or 0) fx.Transform:SetPosition(fx_pos_x, fx_pos_y, fx_pos_z) local newcritter = SpawnPrefab(target.prefab) if target.prefab == "critter_lamb" then if target.AnimState.build == "sheepington_build" then newcritter.AnimState:SetBuild("lamb_winter") elseif target.AnimState.build == "lamb_winter" then newcritter.AnimState:SetBuild("sheepington_build") end elseif target.prefab == "critter_puppy" then if target.AnimState.build == "pupington_build" then newcritter.AnimState:SetBuild("puppy_winter") elseif target.AnimState.build == "puppy_winter" then newcritter.AnimState:SetBuild("pupington_build") end elseif target.prefab == "critter_perdling" then if target.AnimState.build == "perdling_winter" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("perdling_build") else newcritter.AnimState:SetBuild("perdling_rooster") end elseif target.AnimState.build == "perdling_rooster" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("perdling_build") else newcritter.AnimState:SetBuild("perdling_winter") end elseif target.AnimState.build == "perdling_build" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("perdling_winter") else newcritter.AnimState:SetBuild("perdling_rooster") end end elseif target.prefab == "critter_kitten" then if target.AnimState.build == "kitten_winter" then newcritter.AnimState:SetBuild("kittington_build") elseif target.AnimState.build == "kittington_build" then newcritter.AnimState:SetBuild("kitten_winter") end elseif target.prefab == "critter_dragonling" then if target.AnimState.build == "dragonling_winter" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("dragonling_build") else newcritter.AnimState:SetBuild("dragonling_bat") end elseif target.AnimState.build == "dragonling_bat" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("dragonling_build") else newcritter.AnimState:SetBuild("dragonling_winter") end elseif target.AnimState.build == "dragonling_build" then if math.random() < 0.5 then newcritter.AnimState:SetBuild("dragonling_winter") else newcritter.AnimState:SetBuild("dragonling_bat") end end elseif target.prefab == "critter_glomling" then if target.AnimState.build == "glomling_winter" then newcritter.AnimState:SetBuild("glomling_build") elseif target.AnimState.build == "glomling_build" then newcritter.AnimState:SetBuild("glomling_winter") end end newcritter.Transform:SetPosition(Vector3(target.Transform:GetWorldPosition()):Get()) if target.components.perishable ~= nil then newcritter.components.perishable:SetPercent(target.components.perishable:GetPercent()) end target:Remove() return true end After entering the game, there is no problem changing the pet's skin, but strangely, I can only change the pet's skin back to the original state, and I can't change the pet's skin of the original state to other skins. Can anyone help me see what's wrong with this code? Link to comment Share on other sites More sharing options...
Leonidas IV Posted December 29, 2021 Share Posted December 29, 2021 On 12/26/2021 at 11:34 PM, KXWl1 said: elseif target.AnimState.build == "glomling_build" then newcritter.AnimState:SetBuild("glomling_winter") For example here, have you ever tried to print something to see if it's falling here? Link to comment Share on other sites More sharing options...
KXWl1 Posted December 29, 2021 Author Share Posted December 29, 2021 41 minutes ago, Leonidas IV said: For example here, have you ever tried to print something to see if it's falling here? oh I will try later. But I want to ask if the "xxx.AnimState.build == xx" exists? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.