Created
June 6, 2022 19:33
-
-
Save appgurueu/2a4c800efffe6c0bc63bed98b46995d5 to your computer and use it in GitHub Desktop.
Minetest: Redo tool raycast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local eye_pos = player:get_pos() | |
eye_pos.y = eye_pos.y + player:get_properties().eye_height | |
local first, third = player:get_eye_offset() | |
if not vector.equals(first, third) then minetest.log("warning", "First & third person eye offsets don't match, assuming first person") end | |
eye_pos = vector.add(eye_pos, vector.divide(first, 10)) | |
local def = player:get_wielded_item():get_definition() | |
for pointed_thing in minetest.raycast(eye_pos, vector.add(eye_pos, vector.multiply(player:get_look_dir(), def.range or 4)), true, def.liquids_pointable) do if pointed_thing.ref ~= player then --[[do something]] end end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment