Chinken Posted August 12, 2022 Share Posted August 12, 2022 Hey. So, I want my character to change appearance when low on sanity, but I have no idea how it could be done. Can someone please help me out? Link to comment Share on other sites More sharing options...
Leonidas IV Posted August 14, 2022 Share Posted August 14, 2022 local SANITY_THRESHOLD = 30 -- The amount of sanity the character needs to transform. inst.tranformed = false local function SanityTransform(inst) if inst.components.sanity if not inst.transformed and inst.components.sanity.current <= SANITY_THRESHOLD inst.transformed = true -- Code to Tranform elseif inst.transformed then inst.transformed = false -- Code to Untransform. end end end inst:ListenForEvent("sanitydelta", SanityTransform) Maybe this doesn't apply the transformation in world load, then you'll need to save the variable inst.transformed in the inst.OnSave fn and check it in the inst.OnLoad fn. Or simple call the SanityTransform fn in entity creation (below Listen to Event), and if it doesn't work, try call it in inst.OnLoadPostPast fn. Link to comment Share on other sites More sharing options...
Chinken Posted August 14, 2022 Author Share Posted August 14, 2022 3 hours ago, Leonidas IV said: local SANITY_THRESHOLD = 30 -- The amount of sanity the character needs to transform. inst.tranformed = false local function SanityTransform(inst) if inst.components.sanity if not inst.transformed and inst.components.sanity.current <= SANITY_THRESHOLD inst.transformed = true -- Code to Tranform elseif inst.transformed then inst.transformed = false -- Code to Untransform. end end end inst:ListenForEvent("sanitydelta", SanityTransform) Maybe this doesn't apply the transformation in world load, then you'll need to save the variable inst.transformed in the inst.OnSave fn and check it in the inst.OnLoad fn. Or simple call the SanityTransform fn in entity creation (below Listen to Event), and if it doesn't work, try call it in inst.OnLoadPostPast fn. Thank youu, although it's still unclear to me how do I make my character change textures after transforming, any help? Link to comment Share on other sites More sharing options...
Leonidas IV Posted August 14, 2022 Share Posted August 14, 2022 1 hour ago, Chinken said: Thank youu, although it's still unclear to me how do I make my character change textures after transforming, any help? Wilba, for example, changes its build: inst.AnimState:SetBuild("werewilba") 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.