Is it possible to animate ONLY the x-axis of a material's UV offset?

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

I’m animating my character’s eyes by changing the UV offset of the material along the x-axis, to make them squint, look left or right, blink, etc.

I am separately setting the y-offset with code, to change the style of the character’s eyes (with lashes, without, etc). My problem is that the animation is overriding this y value and setting it back to 0.

Is there a way to make an animation control the x-offset without changing the y-offset? Or do I need to use a separate texture for each eye style?

Thanks!

By animate with code, do you mean interpolation with Tween? If so, try:

interpolate_property(material, "uv1_offset:x", init_val, final_val, duration)

Otherwise, show us your code so that we can better understanding your frustration.

imjp94 | 2020-03-26 14:57

Thank you imjp94!

Sorry I was unclear, I’m not trying to animate with code, I’m changing the y-offset of the UVs with code and the x-offset with animation, but the animation was overriding my code changes.

Your answer pointed me in the right direction - I just had to add “:x” at the end of my animation track, and that fixed it.

Ben Rolfe | 2020-03-27 05:36

:bust_in_silhouette: Reply From: Ben Rolfe

imjp94 pointed me in the right direction. I added “:x” to my animation track (it now looks like “armature/Skeleton/body:material/1:uv1_offset:x”) and it no longer changes the y-offset.

I added an “:x” to my frame_coords, so it looks like “frame_coords:x”, and now it doesn’t seem to let me add frames to the timeline. Also, this is the only place I’ve seen anything like this mentioned, so maybe I just did it wrong, can you give more detail on what you did, or possibly some screenshots, because if I can get this to work it’ll save me a lot of time.

MyNameIsntBob | 2020-10-25 16:48

ok, I ended up finding it out. I just added key nodes before swapping it over to framecoords:x, then clicked on each frame and set the value. While yes it does work it’s kind of annoying

MyNameIsntBob | 2020-10-26 03:10