+1 vote

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!

in Engine by (57 points)
edited by

1 Answer

0 votes

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

by (1,939 points)

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.

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 Frequently asked questions and 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 [email protected] with your username.