0 votes

Hi there,

I was playing with the draw function and I just can't get drawpolygon to work and I dont get why. The other methods seem to work with the same set of variables. My scene is a Node2D with this simple script:

extends Node2D
var pts = PoolVector2Array()
var uvs = PoolVector2Array()
var clrarr = PoolColorArray()
var clr = Color(1,1,1,1)
func _draw():

    for i in range(4):
        var myx = floor(rand_range(100,600))
        var myy = floor(rand_range(100,600))
        pts.append(Vector2(myx, myy))

    #draw_polyline(pts,Color(1,0.5,0,1), 1.0, false)
    #draw_polyline_colors(pts,clrarr, 1.0, false)
    #draw_multiline(pts, clr)
    #draw_primitive(pts, clrarr, uvs, null, 3.0, null)

    #won't work
    #draw_colored_polygon(pts, clr, uvs, null, null, false)
    #draw_polygon(pts, clrarr, uvs, null, null, false)

Any advice or hint what's wrong?

asked Oct 6, 2018 in Engine by Zombieakopaluetze (16 points)

Ok, it kind of works with this line, when I not try to set the uv-PoolVector2Array. I guess this uv-array needs another size than the corresponding points array:

draw_colored_polygon(basepoints, clr, PoolVector2Array(), null, null, true)

But not with the random point positions. Seems like there must be some kind of order to them, so that the borderlines dont intersect or soemethings like that. I'll try to figure it out.

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.