0 votes

Is it possible to copy an array created by ArrayPropertyEdit as code? I'm looking for a way to create CollisionPolygon2D dynamically, since now I have to edit it in the editor, type the polygon points array by hand, and then create a ConvexPolygonShape2D from that array, which is very cumbersome. Thanks.

in Engine by (15 points)

2 Answers

0 votes
Best answer

You may try get_polygon() and set_polygon(Vector2Array polygon) of the CollisionPolygon2D node.

by (509 points)
selected by

Can I access CollisionPolygon2D in the game? In the doc it said This is not present when running the game. so I'm a little confused. And I can't copy text from the console neither. So many thing is not copyable in Godot.

Figured it out. I have to launch Godot from Terminal to get properly console output. Now I can copy those values!

+1 vote

You may use "Copy Params" and "Paste Params" from Inspector panel after selecting your CollisionPoligon2D -> ArrayPropertyEdit

enter image description here
enter image description here

-j

by (1,464 points)
edited by

Well, I need to copy the array as code to paste it in a script so this won't do. But somebody might want this, too.

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.