Jump to content

Help with Custom Character


Recommended Posts

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
Share on other sites

@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_amtelse
inst.components.locomotor.bonusspeed = inst.components.locomotor.bonusspeed - boost_amt
end

But 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")end

You can use the same condition in your code.

local snow_thresh = SeasonManager:IsWinter() and 5 or -5if (SeasonManager:GetTemperature() < snow_thresh) then    -- Is snowingend

Alternately, you could also listen for the snowstart event. That would probably be more efficient too.

 

Link to comment
Share on other sites

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.

×
  • Create New...