Skip to content

Instantly share code, notes, and snippets.

@Giacom
Created October 31, 2016 16:37
Show Gist options
  • Select an option

  • Save Giacom/2054770f43b1467cbbd4047ab27b40df to your computer and use it in GitHub Desktop.

Select an option

Save Giacom/2054770f43b1467cbbd4047ab27b40df to your computer and use it in GitHub Desktop.
var polygon = child.get_polygon() # Replace with the new vector2array that you want to set
var polygonShape = ConcavePolygonShape2D.new()
var segments = Array()
segments.resize(polygon.size() * 2)
for i in range(polygon.size()):
segments[(i << 1) + 0] = polygon[i]
segments[(i << 1) + 1] = polygon[(i + 1) % polygon.size()]
polygonShape.set_segments(segments)
add_shape(polygonShape) # Probably will want to replace with set_shape instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment