I've been trying to draw a similiar lines on the screen show above for debuging purposes.

i tried using line3D plugin but plugin wasnt working for some reason (here is the plugin link ). So i tried using line2D as a child in UI nodes and managed to draw a line. But i cant move the second point of the line2D to the object i want it to follow.

This is what ive achieved so far

And this is what i want it to do

i have no idea how to achieve this, can anyone help me out?
sorry for the bad english

So you place a canvas item on the screen, this will be like a piece of paper you draw on (the dimensions will be the full screen). I think a node like Node2D will work for this. Then you use the drawing functions like draw_line to draw 2D lines on the screen.

https://docs.godotengine.org/en/stable/tutorials/2d/custom_drawing_in_2d.html

You would use the Camera function unproject_position to convert a 3D point into a 2D point.

https://docs.godotengine.org/en/3.1/classes/class_camera.html#class-camera-method-unproject-position

  • tunu replied to this.

    cybereality
    So its better than nothing, i managed to draw lines on the screen (but using custom draw wasnt working so used Line2D).
    But its pointing at the center of the scene, not the object i wanted it to point at

    As you can see its pointing to center



    Here is my code

    cybereality ye, reason why its saying null is player's raycasr isnt colliding anything. Its not related to the problem im facing

    I see two problems. The enemy origin is in local space, you need to use global space.

    enemy_node.global_translation

    Second, I don't see where you are setting the first point in the line (at index 0). This needs to be at the other point, which is not clear from your code where that needs to be.

    • tunu replied to this.

      cybereality
      Thank you so much, that fixed the problem. Thank you for your time and help. have a nice day.