How to animate transport belt with perspective properly

Godot Version



I am currently doing this animation by increasing the texture_offset.y of Polygon2D with texture_repeat = ENABLED.
You can notice how the transformation is done on two triangles separately making a weird illusion.

I want the transformation to happen uniformely.

Any ideas, how can I animate this properly?

You’ll want to either do that in the UV’s on the polygon you are drawing on, so when you offset the y it’ll get smaller at distance, or see if there are any ways to skew the polygon you are applying it to, either by some 3D tilt away from the camera (hack), or drawing your own shape and see if the UV’s stay 0 to 1.

Not sure I understand what you mean with the UVs. Because I am happy with the shape, with static transformation, however when I start rolling, it’s obvious, that the transformation is not ideal.

Here are screenshots of my setup of polygon and UV:

Screenshot from 2024-04-29 23-53-26

I was playing with the Polygon2D, texture and UVs little more and got this weird behavior. Is this how the Polygon2D should behave, or is it a bug?

I would expect, that the texture gets stretched everywhere in the polygon, as per the UV setup.

I think you’ll spend more time getting the shape or material to work than just making your own mesh and plugging it into a MeshInstance2D.

Try and make a mesh that tapers like you want it as the mesh itself, but in the UV’s of that mesh make sure it’s 0 to 1 in the UVs, ie it uses the full texture. Then when you offset the texture in the material on the y it should slide right across nicely.

I would make sure that the planar mesh you make has some spans across it so the offset of the texture won’t act odd, so make your mesh like a plan that has like 10 segments on the y (at least).

You might need to do some UV tweaking on the Y also to get the perspective right, but that will be fine tuning.

I gave what I was thinking a try and it works pretty well for a 2D mesh and a material that offsets the texture coordinates to get the effect.

You make a mesh in what application you want, and import it and place it in a MeshInstance2D and apply your conveyor material, you can use the mesh and it’s UV’s to control how the texture slides across the mesh.

Here is the mesh in the clip below, the mesh itself has the perspective taper where the horizontal spans taper too, ie they get closer to eachother as they go up. The UV’s are just linear and 0 to 1.

Note, it seems that the mesh used in a MeshInstance2D needs to be square and offset weirdly, not sure why that is, but you just scale the node in godot to get it to stretch like you want it to be.

Then in the material you setup the shader to do something like:

that you modify slide to make the conveyor belt move.