Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uv_offset = [0, 0]
- def init(c):
- # Copy UVs to second channel using an identity matrix.
- c.owner.meshes[0].transformUV(-1, mathutils.Matrix(), 1, 0)
- def update(c):
- # Transform stored original values and write to first channel.
- uv_offset[0] += SPEED_X
- uv_offset[1] += SPEED_Y
- uv_mat = mathutils.Matrix.Translation((uv_offset[0], uv_offset[1], 0))
- c.owner.meshes[0].transformUV(-1, uv_mat, 0, 1)
- from bge import logic # get the controller that executes the script
- cont = logic.getCurrentController() # get the object that uses the controller
- own = cont.owner
- speed_x = 0.002 # speed by which the coordinates are moved
- speed_y = 0.0 # speed by which the coordinates are moved
- mesh = own.meshes[0] # access the mesh of the object in question
- v_array = mesh.getVertexArrayLength(0) # how many verts are there?
- for v in range(0,v_array): # go through the uv's of every vert
- vert = mesh.getVertex(0,v)
- uv = vert.getUV()
- uv[0] += speed_x # change the uv coordinates. uv[0] = x, uv[1] = y
- uv[1] += speed_y
- vert.setUV(uv) # get the game engine to notice the change!!
Add Comment
Please, Sign In to add comment