Debug 3D Gizmos

panicqpanicq Posts: 11Member
edited February 14 in Programming


I would like to know if it's possible to debug 3D gizmos (Wire spheres, cubes or even lines) in godot (like in Unity using the OnDrawGizmos or the Debug.DrawRay methods) ? I'm currently working on procedural mesh generation and it is a very usefull debugging tool.

Thank you in advance !


  • TwistedTwiglegTwistedTwigleg Posts: 1,943Admin

    I do not think there is any debug drawing capabilities in Godot that are similar to Unity’s debug draw functions, unfortunately.

    You can use create those shapes using one of Godot’s procedural generation methods (documentation). You can add tool keyword to the script if you want it to execute in the editor.

    Also, welcome to the forums!

  • panicqpanicq Posts: 11Member

    Thank you for welcoming me :)

    In the end I will probably make my own utils methods with the draw node and the Tool attribute, thanks.

  • panicqpanicq Posts: 11Member
    edited February 16

    I've create a simple C# script capable of drawing lines, I will expand it with other usefull functions.

    **However ** I've two issues, the SetColor isn't coloring the geometry and nothing is showing in the editor's viewport while I can see it working in the game.

    Any thought about this ?

        using Godot;
        using System;
        using System.Collections.Generic;
        [Tool] // Not working in editor
        public class DebugUtils : ImmediateGeometry
            public static DebugUtils instance;
            List<Vector3> points = new List<Vector3>(); 
            public override void _Ready()
                if(instance == null)
                    instance = this;
                    GD.PrintErr("Duplication of singleton !");
            private void AddLine(Vector3 a, Vector3 b)
            public static void Line(Vector3 a, Vector3 b)
                instance.AddLine(a, b);
            public override void _Process(float delta)
                SetColor(new Color(1, 0, 0, 1)); //Not working...
                if (points.Count >= 2)
                    for (int i = 0; i < points.Count - 1; i+=2)
                        AddVertex(points[i + 1]);

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file