Hello everyone! I’m making a game about fishing and I need to attach a fishing line to a hook. The hook is animated via go. animate and in the video you can see that there is a delay in drawing the line before diving into the water. Please tell me if it is possible to avoid this somehow?
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
Thanks. It would certainly be easier to draw a line from point A to point B, but apparently I will have to look for a solution with a pixel square.
UPD: I tryed your hack and it works pretty good!