How do you use a ConvexPolygonShape2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By godotnoobperson

I don’t understand how to create a collision shape using ConvexPolygonShape2D. What is the step-by-step process of creating one?

:bust_in_silhouette: Reply From: kidscancode

ConvexPolygonShape2D does not have an editor interface, but you can use it in code. You assign a PoolVector2Array to its points property. Example:

var poly = ConvexPolygonShape2D.new()
poly.points = PoolVector2Array([Vector2(0, 0), Vector2(10, 0), Vector2(0, 10)])
$CollisionShape2D.shape = poly

If you want to draw/edit a collision polygon in the editor, use CollisionPolygon2D instead.