Describe the project you are working on:
Checking out Game engines
Describe the problem or limitation you are having in your project:
I have to create my own Sprite by myself even if I want to use a basic shape like a triangle
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Add a shape node 2d to handle simple shape objects
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
A shape2d object that has different basic shapes
If this enhancement will not be used often, can it be worked around with a few lines of script?:
Not sure still a noob
Is there a reason why this should be core and not an add-on in the asset library?:
I don't really know I come from unity background which has it as a core object
I also agree this should be in there. We have something similar for Meshes, but for 2D, there's no easy way (that I know of) to just create a simple shape Sprite.
Are you familiar with the Polygon2D node? https://docs.godotengine.org/en/3.2/classes/class_polygon2d.html
Or do you want to have a set of predefined polygons that you can choose from?
I believe this is for the latter
I am familiar with the polygon node 2d @BeayemX but with the polygon node your shape is offset and gives really bad behavior. I see the polygon node as a way of creating objects like grounds, or objects that don't require precise position. And also the shape is never really accurate. There are lot of problems using the polygon node to create a shape that is used for character movement
I was about to create a proposal related to this then I saw this proposal so I totally agree with this proposal
See also #112 and https://github.com/godotengine/godot/issues/6750.
your shape is offset
That depends on where you are drawing. If your Polygon2D contains the center of your scene, placing instances of your scene should be straight forward and work as expected.
objects that don't require precise position. And also the shape is never really accurate
You can use grid snapping in the 2D viewport to make the points' position precise or adjust the values in the inspector.
There are lot of problems using the polygon node to create a shape that is used for character movement
Like what? The Polygon2D node is just a visualization. This should not have any effect on the character movement.
Overall feedback
These proposals usually work better if we understand what you are trying to do and where the problem occurs. Things like
gives really bad behavior
are hard to relate to if we don't know your use case.
What exactly are you trying to accomplish?
What steps are you taking and where does the problem occur that you are trying to solve.
How does this proposal improve the situation?
godotengine/godot#37903 (available since 3.2.2 released yesterday) makes it possible to achieve visuals similar to "Visible Collision Shapes" option via script to draw any Shape2D resources, but there's no way to draw a texture over such shape alone as in Polygon2D, which is much more superior anyways I think, because you can represent any shape with it visually (even if you draw a circle, that's still approximated by series of arcs).
So I'm thinking that it should be made possible to add a tool to Convert Shape2D to Polygon2D as well to get the best from both worlds, either directly in the engine or as independent plugin.
I think it will be better as a plugin because for android developers like me I don't really see Godot allowing aab format as of now which makes the code heavier and also the feature isn't really much used at least from how I see it
I think it will be better as a plugin because for android developers like me I don't really see Godot allowing aab format as of now which makes the code heavier and also the feature isn't really much used at least from how I see it
@AndroidGod101 I actually disagree with you on this one because there is a 3D shape creation node why not have one for 2D, I see that as totally breaking consistency. And as of Godot 3.2.3 there will be support for android aab format (I hope ) because there have been a lot of requests for it check #342 . I don't know much about how frequently it will be used but from my Idea every game uses at least 1 shape
For platformers you could use a rectangle shape to create platform and just give it a color or texture resource
If you are creating a simple racing game just use circles for the tyre.
But these are just a few uses on videos I have seen on Youtube where simple shapes are used to create amazing games
@AndroidGod101 Please don't derail the discussion with unrelated proposals. Generally, we want to review proposals individually, not in relation to others.
So do we have a go on this proposal?
@I7SOD We don't really have a formal go/no go process (yet). That said, I think we need a bit more discussion to see how we should actually implement this feature. There's rarely only one way to go about implementing something.
your shape is offset
That depends on where you are drawing. If your Polygon2D contains the center of your scene, placing instances of your scene should be straight forward and work as expected.
One of the issues is likely godotengine/godot#12353, but Polygon2D is only visual, unless you set the collision shape from Polygon2D.polygon property directly via code.
I'm writing VisualShape2D node in a module I'm developing: GoostGD/goost#2, can this implement the proposal @I7SOD?
A shape2d object that has different basic shapes
You can create your own basic shapes by editing ConvexPolygonShape2D resources and saving that to disk to be reused on per-project basis. Of course there are existing CircleShape2D and similar which are already builtin.
@Xrayez Yeah that should solve this proposal well-done on the hardwork 馃檪
Thanks, and yeah do not get confused, the class I've made won't be part of the Godot out of the box, but I can make a pull request directly in Godot if core developers find the implementation useful, but don't expect much given previous decisions.
The reason for making this in C++ is that I'm reusing quite a bunch of core functionality provided by Godot, but which is not exposed to scripting (like AbstractPolygon2DEditorPlugin, get_tree()->get_debug_collisions_color()) etc.
Thanks, and yeah do not get confused, the class I've made won't be part of the Godot out of the box, but I can make a pull request directly in Godot if core developers find the implementation useful, but don't expect much given previous decisions.
I totally understand
The reason for making this in C++ is that I'm reusing quite a bunch of core functionality provided by Godot, but which is not exposed to scripting (likeAbstractPolygon2DEditorPlugin,get_tree()->get_debug_collisions_color()) etc.
Okay that's cool this should bring a conclusion to this proposal. Again well done
As I'm thinking about it, my particular implementation is quite similar to CollisionShape2D in a way that both share and expose Shape2D resource, and the VisualShape2D allows to specify any color for drawing, and the shape can be synced with use_parent_shape (from CollisionShape2D etc).
So, it might be safe to say that, in most cases, the need to draw shapes comes from the need to draw physics bodies without using sprites, and the shape perfectly represents it.
So, in order to possibly address this issue on the core level, it would be just nice for the CollisionShape2D to:
release).Some features/bug-fix can be ported to Godot (like godotengine/godot#21394), as VisualShape2D in GoostGD/goost#2 does allow editing polygon-based shapes already (with some limitations), and I could probably work on that as well.
EDIT: On the other hand, you'd have to make similar thing for CollisionPolygon2D, and perhaps some other node which would use a Shape2D in the future (other than physics), so might not be worth it. Creating a dedicated class for visualizing shapes is probably the best idea, but that means adding another class in Godot, which is bloat.
Some discussion happened regarding being able to edit polygon-based shapes through CollisionShape2D node alone in godotengine/godot#21394, but reduz is not so keen implementing this kind of thing for physics-only stuff, which kinda makes sense, but not in the relation to this proposal (which likely won't be implemented in core anyways), so providing a warning instead: godotengine/godot#40091.
Being able to override the collision debug color and bypassing "Visible Collision Shapes" option per each node would still be useful I think, but it's sorta already possible to do via script given godotengine/godot#37903. The only issue left is poor usability for beginners to figure out on how to actually do this.
This is now implemented in Goost: GoostGD/goost#2, so the proposal can be closed, unless other Godot core developers would like this feature to be available directly in the engine of course. 馃槈
There are still some usability issues as described in the proposal I've made for Godot: #1157, but that's not high priority and can be solved on the module level in any case.
It is indeed possible to make this work with GDScript as well and make a simple plugin out of it, but I don't see the point remaking what's already available in core, and I just personally prefer this kind of feature to be closer to core. Goost provides some useful geometry methods which could also enhance the experience further. I invite people to checkout the VisualShape2D class and perhaps if more people could find it useful, it can be merged to Godot eventually.
Okay thanks for the feedback I will see what I can do from my end to make this work
Most helpful comment
I also agree this should be in there. We have something similar for Meshes, but for 2D, there's no easy way (that I know of) to just create a simple shape Sprite.