0 votes

Hi,

I'm using the Navmesh Demo as a template to create 3D lines. The code below generates 3D lines at random locations.

Problem: using the clear() method for the GeometryInstance node (renamed 'draw' here) does not clear the vertex buffer of the node. I know this because running the scene creates an increasing amount of randomly positioned lines.

How can I clear this buffer without having to assign the pointer to the node as null?

extends Spatial

var im

func _ready():
        var material = SpatialMaterial.new()

        set_process(true)

        im = get_node("draw")
        im.set_material_override(material)
        pass

func _process(delta):
        im.begin(Mesh.PRIMITIVE_LINE_STRIP, null)
        im.clear()

           #create 2 points per line
        for n in range(2):
            var point = Vector3(randf()*10-5, randf()*10-5, randf()*10)
            im.add_vertex(point)
        im.end()
        pass
in Engine by (85 points)
retagged by

Are you actually talking about ImmediateGeometry? GeometryInstance does not have clear function.

    im.begin(Mesh.PRIMITIVE_LINE_STRIP, null)
    im.clear()

Did you try clearing before begin?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.