UV coords for a AtlasTexture sprite size

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By peterhoglund

How would I get the UV coords based on the sprite size of a AtlasTexture sprite. If I use UV in my shader it seems like it will be based on the full atlas texture.

I am trying to animate a sprite swaying back and forth, but I only want the top part of the sprite to animate. So in my shader I offset the pixels based on UV.y which will be 0 at the top and 1 at the bottom. This works because my image is at the top of the atlas, but when I flip the direction (so that 0 will be at the bottom, which is what I want) it will start to sway very much, I suppose it is because 0 is now way down at the bottom of the atlas and not at the bottom of the sprite edges.

Edit: To be more clear, I am animating the sway in a shader which is also what I need help with. Thanks!

:bust_in_silhouette: Reply From: rakkarage

ya maybe try flipping by setting x or y scale to negative or sprite has a FlipX and FlipV properties too

I realise I’m a bit unclear in my description, but what I need help with is to set this up in a shader and not for the nodes transform.

peterhoglund | 2020-08-09 17:25