2020-04-10 03:06:57 +02:00
|
|
|
function weather_mod.set_headwind(player)
|
2020-04-09 18:31:52 +02:00
|
|
|
local movement = vector.normalize(player:get_player_velocity())
|
2020-04-10 03:06:57 +02:00
|
|
|
local product = vector.dot(movement, weather_mod.state.wind)
|
|
|
|
-- logistic function, scales between 0 and 2
|
2020-04-09 18:31:52 +02:00
|
|
|
-- see https://en.wikipedia.org/wiki/Logistic_function
|
2020-04-10 03:06:57 +02:00
|
|
|
local L = 1.6 -- maximum value
|
|
|
|
local k = 0.15 -- growth rate
|
|
|
|
local z = 0.8 -- midpoint
|
|
|
|
local o = 0.1 -- y offset
|
|
|
|
local factor = L / (1 + math.exp(-k * (product - z))) + o
|
2020-04-09 18:31:52 +02:00
|
|
|
weather_mod.add_physics(player, "speed", factor)
|
|
|
|
end
|