From ca8570e639b7e97032610b8bfa2e3440e5d0fc9f Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sun, 8 Sep 2024 16:29:29 -0500 Subject: [PATCH] Inline dir_to_pitch() and use correct formula for pitch --- mods/ITEMS/vl_projectile/init.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mods/ITEMS/vl_projectile/init.lua b/mods/ITEMS/vl_projectile/init.lua index 5104a17a5..7185727a7 100644 --- a/mods/ITEMS/vl_projectile/init.lua +++ b/mods/ITEMS/vl_projectile/init.lua @@ -7,11 +7,6 @@ local YAW_OFFSET = -math.pi/2 local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) local enable_pvp = minetest.settings:get_bool("enable_pvp") -local function dir_to_pitch(dir) - local xz = math.abs(dir.x) + math.abs(dir.z) - return -math.atan2(-dir.y, xz) -end - function mod.projectile_physics(obj, entity_def, v, a) local le = obj:get_luaentity() local entity_def = minetest.registered_entities[le.name] @@ -54,7 +49,7 @@ function mod.projectile_physics(obj, entity_def, v, a) -- Update projectile yaw to match velocity direction if v and le and not le._stuck then local yaw = minetest.dir_to_yaw(v) + YAW_OFFSET - local pitch = dir_to_pitch(v) + local pitch = math.asin(vector.normalize(dir).y) obj:set_rotation(vector.new(0,yaw,pitch)) end end