Animated UV texture (offset)?

Hey. I was little surprised keyframing offset for uv texture isn’t working directly for game engine.
I saw someone’s animated flame, but that animation isn’t “smooth”.

(My test was for scrolling text on a monitor from left to right).

What solutions are there for animating textures in BGE?

What version of blender are you using?

I made something similar not long ago. See the attached blend file UV_Change.blend (621 KB)
Move the camera with the arrow keys and the texture changes UV position.

If you don’t know python tell me and I can explain the script.

In 2.56 (r35382) your demo: arrows only move the camera, texture position isn’t changing.

Because the script is made for Blender 2.49b.
The Python API changed so that’s why it doesn’t work. You could rewrite the script for Blender 2.56 or I heard about a script convector between 2.49 and 2.5x that you can try.
Anyway the thing is the get all vertex and change their uv position with python.

Thankies for the tip, will fizzle with Python to do the trick.

You’re welcome. I always found a way to do something I want in Python, the only limitation I see is the computer power:)

Hey it’s 2018 and I’m trying to animate UV texture offsets in viewport … anyone know how to do this?

this will scroll the uv of an object

    obj = own.scene.objects['an_object']  
    mesh = obj.meshes[0]
    verts = mesh.getVertexArrayLength(0)

    for i in range(0, verts):

        point = mesh.getVertex(0, i)
        uv = point.getUV()
        #speed property on the object (scroll speed)
        uv[1] += own['speed'] # 0=x,1=y axis

with enough time, the uv will lose precision causing black artifacts.

i suggest creating a timer to count up and reset the uv to zero after one texture width.

Thanks for pointing that out, personally didn’t encounter that problem yet.

Thanks for the reply and code @Cotaks

Ideally I would like to keyframe the offset x,y values

i dont think you can.

You can’t do it with keyframes, the engine doesn’t like that. At least for now it doesn’t.

A note: when changing values on mesh data like UVs, all objects that use the same mesh are affected.
That means if you run the script on three objects, you get the displacement at three times speed.
So run the script only once per mesh if you don’t want that to happen.


You can do it using a similar idea as the scrolling. The easiest way I’ve seen is to do it is to create a list of lists of co-ordinates, and use that list to set the UV positions.

Here is how you can create the list of co-ordinates:

def coords(num):
	coords_list = []
	for x in range(0,num+1):
	return coords_list

def uvListBuilder(columns,rows):
	# Returns an accessable list which can be accessed like:
	# list[row][element]
	h_list = coords(columns)
	v_list = coords(rows)
	final_list = []
	indexes = []
	for num in range(0, rows):
	for y in indexes:
		inner_list = []
		for x in range(0,columns):
			inner_list += [[[h_list[x],v_list[y]], [h_list[x+1],v_list[y]], [h_list[x+1],v_list[y+1]], [h_list[x],v_list[y+1]]]]
		final_list += [inner_list]
	return final_list

Then store it in a variable somewhere:

GameLogic.UVMap = uvListBuilder(4,3)

Then on the object that has the UV on it, do this to move it:

column = 2
row = 1

mesh = own.meshes[0]
for x in range(0,4):