lochaodhan Posted June 7, 2015 Share Posted June 7, 2015 For one of my character mods i would like to scale the movement speed with the player's sanity. I have the code ready but for some reason I can't seem to get it to work quite right. The speed only changes if the character dies then revives or reloads into the world. Link to comment https://forums.kleientertainment.com/forums/topic/54945-need-help-with-a-stat-change-i-am-not-a-very-good-coder/ Share on other sites More sharing options...
Renarii Posted June 7, 2015 Share Posted June 7, 2015 You're going to want to add an event handler when the players sanity changes. I'm not sure how to do this but that's what I'd look into. Link to comment https://forums.kleientertainment.com/forums/topic/54945-need-help-with-a-stat-change-i-am-not-a-very-good-coder/#findComment-644975 Share on other sites More sharing options...
Seiai Posted June 7, 2015 Share Posted June 7, 2015 (edited) @lochaodhan,put that in your characterprefab near the end of the master_init:inst:ListenForEvent("sanitydelta", function(inst) inst.components.locomotor.runspeed=TUNING.WILSON_RUN_SPEED*inst.components.sanity.current/100 end) Edited June 7, 2015 by Seiai Link to comment https://forums.kleientertainment.com/forums/topic/54945-need-help-with-a-stat-change-i-am-not-a-very-good-coder/#findComment-645003 Share on other sites More sharing options...
DarkXero Posted June 7, 2015 Share Posted June 7, 2015 @lochaodhan, upload your character's prefab file and we will tell you why that happens. Link to comment https://forums.kleientertainment.com/forums/topic/54945-need-help-with-a-stat-change-i-am-not-a-very-good-coder/#findComment-645004 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