• 3D
  • How to draw in 3D?

Hi! Sorry for the generic title. Didn't know how to phrase this more precisely. Being rather new to 3D in Godot I am wondering how to create something similar to the following screenshot from Homeworld. There, when you want to issue a move order, a disc is being drawn for 2D orientation and an additional line for the third axis:

I have no idea what technique / feature to use in order to implement this in a Godot 3D environment. At this point I'm jusr asking for any pointers towards (a) possible solution(s). Thanks in advance!

You can mix 2D and 3D in Godot freely. Unlike other engines, Godot allows you to combine every engine feature together. That said, the 2D and 3D are separate rendering (2D is not fake 3D) but they can be composited easier. You can see the API here, on how to draw lines and arcs and stuff.

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

This is for 2D, but the same code would work. You would just have a 2D layer over the 3D game. Then you can convert a 3D point into 2D screen space. You can do this with the function unproject_position() on the camera.

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

Then draw just like normal. I think any CanvasItem can be drawn onto, so you could make an empty Node2D to do the lines. However, if you need 3D objects like ships or planets to clip and interact with the lines (not just a 2D overlay) then you will need to use the 3D drawing features. These are not as robust as the 2D, but should be good enough if you work with it for a bit. However, 2D will always look better, I know there are some issues with stuff like anti-aliasing and uniform line width when drawing in 3D. But it is possible.

Here is a tutorial for drawing in 3D, it is much more complicated, so I would try the 2D version first to get it working, and convert it to 3D later if necessary.

https://kidscancode.org/godot_recipes/3d/debug_overlay/

@cybereality said: ...

Will look into these. Thank you!