0 votes

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

in Engine by (39 points)

1 Answer

+1 vote
Best answer

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.

by (20,475 points)
selected by
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.