Open Xascoria opened 3 years ago
The functions right now are in editor code, they aren't actually in the core engine. That means that are in the "tools" build of the engine, but they aren't included in the release templates.
Accordingly, this proposal is actually asking for new functions to be added to the engine rather than for functions to be simply exposed to scripting.
One of the nice things about Godot is that the editor is built as a Godot app. This means that you can actually duplicate the editor functionality in GDScript without adding anything into the core engine!
The functions right now are in editor code, they aren't actually in the core engine. That means that are in the "tools" build of the engine, but they aren't included in the release templates.
My bad, I just checked the relevant source code for this part and it is indeed in the editor, but I still think it wouldn't makes much sense for something that is doable in the editor but not via script to exist in the engine.
I still think it wouldn't makes much sense for something that is doable in the editor but not via script to exist in the engine.
Fair enough! :) I'm just trying to help focus the proposal.
After Creating individuals sprite from a colored country sheet (on runtime), I'm unable to create Area2D that I need to be used for detecting mouse position since I can't create a CollisionShape2D at runtime from a sprite.
Out of curiosity, can't you use a few premade CollisionShapes for all country flags instead of generating them from the images?
As far as I know, most country flags have the same size/aspect ratio. There are a few exceptions such as Switzerland, but these are usually well-known.
@Calinou: Nope, quote from Wiki: The ratios most commonly used are 2:3, used by 85 of 195 sovereign states, followed by 1:2, used by 54 sovereign states.
That's two different ratios, plus you get all the oddities like Switzerland, Albania and Nepal.
Out of curiosity, can't you use a few premade CollisionShapes for all country flags instead of generating them from the images?
@Calinou: Oh mate, you misunderstood, if it's flag I can probably write a func to make me custom sized Rect2D and deal with the exception myself, I'm talking about country borders here
If we're going to add such conversion functionality in core, I think we should go for systematic approach for the code which deals with converting different types. Perhaps just like GDScript has convert()
function, but this shouldn't be specific to GDScript. Could be technically implemented as a Convert
singleton! In fact I think this might be a nice idea to be implemented in Goost too... goostengine/goost#7.
Alternatively, come up with a convention that each class should define it's own convert(to_class: String)
method if needed, this way there's no way to bloat the Sprite
API.
The problem is the same as for having randomization methods in each of the core class, which also bloats the API... That's why I also previously proposed #1741 so that we can add more useful methods to Random
singleton without touching core classes (this is already implemented in Goost, btw).
The Shaggy Dev’s Video Titled, “Pixel-perfect collisions on sprites in Godot, seems relevant, so I’m posting it here. He shows how to generate collisions shapes from sprites in code during runtime.
Describe the project you are working on
(Irrelevant) A game with a world map
Describe the problem or limitation you are having in your project
After Creating individuals sprite from a colored country sheet (on runtime), I'm unable to create Area2D that I need to be used for detecting mouse position since I can't create a CollisionShape2D at runtime from a sprite.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Expose the following functions to be callable in script: Sprite: Convert to Mesh2D Sprite: Convert to Polygon2D Sprite: Create CollisionPolygon2D Sibling Sprite: Create LightOccluder Sibling
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
var mesh = Sprite_ref.convert_to_mesh2d()
or something along that lightIf this enhancement will not be used often, can it be worked around with a few lines of script?
Pretty much impossible to worked around for some of them, like for example
Create CollisionPolygon2D Sibling
can only be worked around if you use custom vectorization algo on the sprite and then converts them to positional pointsIs there a reason why this should be core and not an add-on in the asset library?
The functions are already in the core engine, no reason they shouldn't be accessible via script