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 https://forums.kleientertainment.com/forums/topic/142565-need-help-with-making-my-character-have-different-sprites-on-low-sanity/ Share on other sites More sharing options...
Leonidas IV Posted August 14, 2022 Share Posted August 14, 2022 (edited) 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. Edited August 14, 2022 by Leonidas IV 2 Link to comment https://forums.kleientertainment.com/forums/topic/142565-need-help-with-making-my-character-have-different-sprites-on-low-sanity/#findComment-1594261 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 https://forums.kleientertainment.com/forums/topic/142565-need-help-with-making-my-character-have-different-sprites-on-low-sanity/#findComment-1594271 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 https://forums.kleientertainment.com/forums/topic/142565-need-help-with-making-my-character-have-different-sprites-on-low-sanity/#findComment-1594278 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