Goregonzola Posted January 21, 2021 Share Posted January 21, 2021 (edited) Hello-bello! I have a little bit of trouble with my character speed scaling. I use the following coding, but it doesn't seem to work: Spoiler local function fastestevil(inst) local currenthealth = inst.components.health.currenthealth if inst:HasTag("playerghost") then return end if inst.components.health:IsDead() then return end -- stage I if currenthealth <= 150 then inst.components.locomotor.walkspeed = 4 end -- stage II if currenthealth >= 151 and currenthealth <= 350 then inst.components.locomotor.walkspeed = 2.5 end -- stage III if currenthealth >= 351 and currenthealth <= 500 then inst.components.locomotor.walkspeed = 1 end -- stage IV if currenthealth >= 501 then inst.components.locomotor.walkspeed = 0.5 end end In local master_postinit = function(inst): inst:DoPeriodicTask( 0.0, function(inst) fastestevil(inst) end) The speed of my character doesn't change at all. What did I missed? Noteable: I also use a "inst.Transform:SetScale()" local function for the same Health values. Edited January 21, 2021 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/126317-solved-character-speed-scaling-doesnt-work/ Share on other sites More sharing options...
Thomas_klei Posted January 21, 2021 Share Posted January 21, 2021 local function HungerChange (inst) if inst:HasTag("playerghost") then--basic need return end local hunger = inst.components.hunger:GetPercent() > .35 and inst.components.hunger:GetPercent() or .35 local scale = (2.05 * hunger)--gonna have this on config later local damage = hunger > .4 and hunger or .4 local speed = inst.components.hunger:GetPercent() > .8 and .8 or 1 inst.Transform:SetScale(scale*1.3, scale, scale) inst.components.combat.damagemultiplier = damage inst.components.locomotor:SetExternalSpeedMultiplier(inst, "chungus_speed", speed ) print(damage) end I think that the speed in minimal when the size is so huge so i'd use :SetExternalSpeedMultiplyer i'm not sure how to explain this so i'll leave the way i did it here 1 Link to comment https://forums.kleientertainment.com/forums/topic/126317-solved-character-speed-scaling-doesnt-work/#findComment-1418998 Share on other sites More sharing options...
Goregonzola Posted January 21, 2021 Author Share Posted January 21, 2021 @thomas4846 Thanks, I'll experiment with it Link to comment https://forums.kleientertainment.com/forums/topic/126317-solved-character-speed-scaling-doesnt-work/#findComment-1419000 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