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

asked Apr 17 in Engine by SamButers (15 points)

1 Answer

+1 vote
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.

answered Apr 17 by njamster (9,824 points)
selected Apr 17 by SamButers

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.

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.