I have a small problem with Python. In front I have say my Python skill is very poor as well as my English, please excuse that.
In the bge I have created a life and mana bar by shifting the UV map, at the x axis for visual effect, and at the y axis as equivalent to the hitpoints. For the x axis I use the following script that I have found in this forum, posted by HG1. (I just understand the begin and the last 4 lines)
from bge import logic as GL
cont = GL.getCurrentController()
own = cont.owner
#The recomended max. speed is 0.10 and the min. is 0.009
mesh = own.meshes
array = mesh.getVertexArrayLength(0)
for v in range(0,array):
vert = mesh.getVertex(0,v)
uv = vert.getUV()
uv += 0.001
uv += 0
For the y axis I use an animated material that changes the y mapping value in an other material. This way I can control the animation with the logicbrics. That works, but I would like to have a more ‘clean’ solution. To do that I would like to alter the script, to animate both axis with the script, but I do not know how to do that.
So I think, at first I have to include the GameProperty (Life) that represent the hitpoints into the script. So I guess I have to add the following line to the script: life = float(own[‘Life’]).Than I have to get the original location of the UV map and store that in away that it is not altered by the script anymore, and than I have to add ‘life’ to the original location and write that value back to the UV map. But I don’t know how. Can some help me with this problem please.