mirror of
https://github.com/t-affeldt/climate_api.git
synced 2024-12-23 09:20:36 +01:00
8 lines
381 B
Lua
8 lines
381 B
Lua
|
function weather_mod.set_headwind(player, wind)
|
||
|
local movement = vector.normalize(player:get_player_velocity())
|
||
|
local product = vector.dot(movement, wind)
|
||
|
-- logistic function, scales between 0.5 and 1.5
|
||
|
-- see https://en.wikipedia.org/wiki/Logistic_function
|
||
|
local factor = 1 / (1 + math.exp(-0.1 * (product - 0.5))) + 0.5
|
||
|
weather_mod.add_physics(player, "speed", factor)
|
||
|
end
|