Add pitch and yaw offset support to vl_projectile

This commit is contained in:
teknomunk 2024-11-15 17:45:05 -06:00
parent 40a0a934a6
commit 3f14af8b59

@ -53,8 +53,8 @@ function mod.projectile_physics(obj, entity_def, v, a)
-- Update projectile yaw to match velocity direction -- Update projectile yaw to match velocity direction
if v and le and not le._stuck then if v and le and not le._stuck then
local yaw = minetest.dir_to_yaw(v) + YAW_OFFSET local yaw = minetest.dir_to_yaw(v) + YAW_OFFSET + (entity_def._vl_projectile.yaw_offset or 0)
local pitch = math.asin(vector.normalize(v).y) local pitch = math.asin(vector.normalize(v).y) + (entity_def._vl_projectile.pitch_offset or 0)
obj:set_rotation(vector.new(0,yaw,pitch)) obj:set_rotation(vector.new(0,yaw,pitch))
end end
end end
@ -301,7 +301,8 @@ local function stuck_on_step(self, dtime, entity_def, projectile_def)
obj = objects[i] obj = objects[i]
if obj:is_player() then if obj:is_player() then
if self._collectable and not minetest.is_creative_enabled(obj:get_player_name()) then if self._collectable and not minetest.is_creative_enabled(obj:get_player_name()) then
local arrow_item = self._arrow_item local arrow_item = self._itemstring or self._arrow_item
minetest.log("Trying to pick up "..tostring(arrow_item))
if arrow_item and minetest.registered_items[arrow_item] and obj:get_inventory():room_for_item("main", arrow_item) then if arrow_item and minetest.registered_items[arrow_item] and obj:get_inventory():room_for_item("main", arrow_item) then
obj:get_inventory():add_item("main", arrow_item) obj:get_inventory():add_item("main", arrow_item)