# Delay when using draw\_line in update

**URL:** <https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695>\
**Category:** Questions\
**Created:** [June 23, 2021, 9:16am UTC](https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695 "2021-06-23T09:16:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Bulatov](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_bulatov/32/27139_2.png) [@Alexander\_Bulatov](https://forum.defold.com/u/Alexander_Bulatov)\
**Post date:** [June 23, 2021, 9:16am UTC](https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695/1 "2021-06-23T09:16:03Z")

</div>

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?

msg.post(“@render:”, “draw\_line”, {  
start\_point = go.get\_position(“game:/line\_start”),  
end\_point = go.get\_world\_position(“/hook”),  
color = line\_color  
})

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [June 23, 2021, 9:29am UTC](https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695/2 "2021-06-23T09:29:01Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![Alexander\_Bulatov](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/alexander_bulatov/32/27139_2.png) [@Alexander\_Bulatov](https://forum.defold.com/u/Alexander_Bulatov)\
**Post date:** [June 23, 2021, 10:38am UTC](https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695/3 "2021-06-23T10:38:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [June 23, 2021, 11:41am UTC](https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695/4 "2021-06-23T11:41:54Z")

</div>

This is most likely overkill for what you want to do, but it allows you to draw pixels:

[https://github.com/AGulev/drawpixels](https://github.com/AGulev/drawpixels)

There is no other way to draw geometry directly in Defold as far as I know.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 23, 2021, 5:46pm UTC](https://forum.defold.com/t/delay-when-using-draw-line-in-update/68695/5 "2021-06-23T17:46:09Z")

</div>

You can stretch a sprite between two points to draw lines.

[LaserExample.zip](https://forum.defold.com/uploads/short-url/XtqTPCxQpINAg12lSBnQVvWM6N.zip) (4.0 KB)

Also check out this example

> [@Shader for (cubic) bezier curve](https://forum.defold.com/t/shader-for-cubic-bezier-curve/65408):
>
> Hi there! Following a suggestion of @Pkeod, I am posting here a minimal Defold project with a shader for drawing cubic bezier curves. You can use the mouse to move the start and end points and the control points. The controls points define the tangents at the start and end points of the curve. (Note that moving a start/end point does not move the corresponding control point, this may look strange if you are used to a vector drawing program…). Some notes. A (planar) Bezier cubic curve is ju…
