I’ve got a problem, how do I get my slug to bend well against corners and angles when it moves, it’s an animated sprite and I was wondering how to modify the texture dynamically (as if it followed a curve like 3d meshes for example).
You could do that with a segmented model (see Skeleton2D
), you could do that with animation frames that cover all the possible deformations, you could do it as multiple submodels flying in formation… there are lots of ways to do it, depending on your project’s needs.
I’ve already tried several pliemét fram, but when the slug is slow it makes graphic bugs. There’s no way to use curves like in 3d on png images in animatedsprite2d or similar.
It sounds like what you want is a skinned model.
I don’t understand, is it possible to use curves on png?
You can’t apply curves directly to a png, as far as I’m aware.
One thing you can do is create a textured model and use parts of the png to texture the model. You can make either 2D or 3D models that do this.
The way it works is, a model is made (typically, there’s a whole rabbit hole here…) out of points in space (each referred to as a “vertex”). These can be 2D for 2D models, or 3D for 3D models. The vertices are grouped into triangles. Triangles are typically used on modern hardware because they’re coplanar; there’s no way to “twist” a triangle so it’s not flat, which makes the math easier when rendering/rasterizing.
What texturing does (again, typically; any hardware you’re likely to use does this, but there’s a vast menagerie of techniques out there…) is take triangular sections out of a source image and “stretch” those over the triangles. So, as your caterpillar bends, the section that’s bending can stretch and compress as needed and the texture is stretched/compressed to match.
You can do this in 2D or 3D. 3D art packages like Blender support this. You can also do it by hand if you want.
Texturing is done by providing texture coordinates. These are usually specified as UV coordinates (or sometimes ST coordinates), but you can think of U as a [0.0…1.0] position horizontally on the texture, and V as a [0.0…1.0] position vertically on the texture. (0, 0) is one corner, (1,1) is the opposite corner, (0.5, 0.5) is the center of the texture.
So, in addition to the spatial position of each vertex (where it is in x,y for 2D or x,y,z for 3D) you can include texture coordinates. If you search for images of “uv map”, you’ll see source textures for this kind of thing.