Hi @Alexander_Bulatov, nice, I like fishing games!
The draw_line
message is meant to be used for debugging. You could use a sprite instead, with the anchor point at one end, then stretch the scale of it as needed.
Because the physics is moved after the update() function, you may also need to use this hack to be able to keep the sprite in sync with the physics objects:
local EMPTY_TABLE = {}
local VECTOR3_EMPTY = vmath.vector3()
local VECTOR3_ONE = vmath.vector3(1)
local function late_update()
-- This update will happen after game objects have been moved by the physics engine
end
local function queue_late_update()
physics.raycast_async(VECTOR3_EMPTY, VECTOR3_ONE, EMPTY_TABLE)
end
function update(self, dt)
queue_late_update() -- Hack to trigger ray_cast_missed after physics update.
end
function on_message(self, message_id, message, sender)
if message_id == hash("ray_cast_missed") then
late_update()
end
end