I have found that sometimes when I load a particular scene in my game it loads quickly with no problems but other times the FPS drops below 1 and it never goes up. I have narrowed the problem down to this UVscroll code (not mine; I forgot who’s it is) I use to make the water in the river flow:
When I disable this code it works fine every time but I would really like to use this code for the river. Does anyone know why this problem comes up or know of any workarounds for this?
Thanks in advance.
######################
# UV SCROLL SCRIPT #
# by Pepius #
######################
horizontal = 0
vertical = 1
import GameLogic as GL
cont = GL.getCurrentController()
own = cont.getOwner()
mesh = own.getMesh()
array = mesh.getVertexArrayLength(0)
#The recomended max. speed is 0.10 and the min. is 0.009
SPEED = own.speed
try:
DIR = own.dir
except:
dir = 1
for v in range(0,array):
vert = mesh.getVertex(0,v)
uv = vert.getUV()
uv[DIR] = uv[DIR]+SPEED
vert.setUV(uv)
I’m going to have to check into that uv thing, haven’t gotten around to it yet. It looks weird on both scripts because the uv pos never goes back to it’s original, it just keeps getting added to speed. Hard to imagine it. It just looks like there should be a line in there:
if uv > 1:
(tab) uv = 0
or maybe
if uv > 1:
(tab)uv = uv-1
Maybe someone can explain to me why there isn’t. I don’t think uv values are supposed to be greater than 1.
I’m just trying to figure out what’s going on there.
From an opengl article I found:
As I mentioned above, non repeating texture coordinates start at 0.0 (in the bottom left hand corner) and finish at 1.0 (in the top right hand corner).
So, I guess numbers above 1 perhaps get ignored. I don’t know, or is it treating this as repeating textures? It would seem it would have to be ignoring, yet values above 1 seem to be legitimate.
scabootssca, thanks for the script. It looks like it allows for a different number of verts besides four as the other one allowed for. It may or may not have fixed my problem because this problem is so random. Sometimes the physics or rasterizer or some other random factor goes way up and the framerate goes to almost nothing.