TerrieWolff Posted January 20, 2015 Share Posted January 20, 2015 Hello all, first time posting here! I was just wondering if someone could help me with a small scripting question. I wanna make it so that when it's snowing in game my character has a slight movement speed boost. I'm not sure exactly how to go about this. Is it something to do with GetSeasonManager? I know that Snow is considered percipitation like the rain, so it ties into GetSeasonManager():IsRaining(), or am I wrong? I'm really new to all this, and would appreciate a point in the right direction! Link to comment https://forums.kleientertainment.com/forums/topic/49436-help-with-custom-character/ Share on other sites More sharing options...
Blueberrys Posted January 26, 2015 Share Posted January 26, 2015 (edited) @TerrieWolff GetSeasonManager():IsRaining() should work in checking whether it's raining or not.As for the speed boost, modify the locomotor component's bonusspeed variable.-- in a function where "inst" refers to the playerlocal boost_amt = 5if GetSeasonManager():IsRaining() then inst.components.locomotor.bonusspeed = inst.components.locomotor.bonusspeed + boost_amtelseinst.components.locomotor.bonusspeed = inst.components.locomotor.bonusspeed - boost_amtendBut you'll need to put this in a function that runs periodically, not just once. The character's create fn probably won't work.The locomotor component has an OnUpdate function, you could override that and include your bit of code.inst.old_locomotor_OnUpdate = inst.components.locomotor.OnUpdateinst.components.locomotor:OnUpdate = function(dt) inst:old_locomotor_OnUpdate(dt) -- your code here -- Use "self.inst" to refer to the playerend-- Edit: To check whether it's snowing or not, seasonmanager uses this code:local snow_thresh = self:IsWinter() and 5 or -5if self.current_temperature < snow_thresh then self.preciptype = "snow" self.inst:PushEvent("snowstart")else self.preciptype = "rain" self.inst:PushEvent("rainstart")endYou can use the same condition in your code.local snow_thresh = SeasonManager:IsWinter() and 5 or -5if (SeasonManager:GetTemperature() < snow_thresh) then -- Is snowingendAlternately, you could also listen for the snowstart event. That would probably be more efficient too. Edited January 26, 2015 by Blueberrys Link to comment https://forums.kleientertainment.com/forums/topic/49436-help-with-custom-character/#findComment-606083 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