0 votes

Hello.
I have been wondering if Godot has any function to transform or draw a texture with the manipulation of its four points: x0, x1, y0 and y1.

Example of the desired effect is represented below with each point being the red dots:
Kelpie is doing fine

Kelpie has been stretched beyond recognition but is still doing fine

in Engine by (18 points)

1 Answer

+2 votes
Best answer

Create a Polygon2D-node. Select it in the scene tree and add four points to it via the toolbar on top of the 2D scene view by first clicking the green plus icon and then into the scene, where you want your polygon's corner-points to be. Next, in the inspector, set your image as the texture of the polygon. Navigate back to the toolbar and click on the "UV"-icon. A popup will open and allow you to move the UV-points to the corners of your texture. Note that changing the UV-points will not change the corner-points of the polygon we set earlier! If you press "OK" everything between the UV-points will now be mapped (by shearing and stretching) into the area inside your polygon.

by (10,247 points)
selected by

This seems like a good way to solve this, yes.
Using the points section seems to bring the desired effect, although
I have been wondering how to access that through GDScript.
I have seen some functions dedicated to manipulation the bones, UV,
polygons but not the points in there.

But, yes, appreciated.
Seems like what I was looking for.

Was testing out stuff and the points can be modified
through the polygon property, although I was a little
confused in the beginning with the polygon and polygons properties,
one of them having no description.

That being said, all have been solved.

Hello,

Can you explain how to access the points property ?
I want to animate the sprite with a tween.

Thanks

[EDIT -> self solution]

If found a solution :

$Polygon2d.polygon[index of the desired point]
Return Vector 2D coordinates.

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.