Moving texture

Hi
It’s my first thread on the forum but i did a lot of blender since 3 years but i’m a long way trough to be really good:)
So i’m doing a little first game but it’s kinda “big” so i want to put water at a place and i want it to move like in Zelda Oot and some games on Nintendo 64 lol. I searched in a couple of page of this forum but i didn’t find any answer. So if someone knows how to do that :smiley:

Welcome to the forums, I recall a script for the game engine that scrolls a texture, I think it was called UV scroller…

ok thanks :smiley:

uhm sorry but where is that thread?:o

Here’s the script, be forewarned that using it too much will result in a framerate drop. Don’t forget to credit Pepius!

######################
#  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




for v in range(0,array):
    vert = mesh.getVertex(0,v) 
    uv = vert.getUV() 
    uv[1] = uv[1]+SPEED 
    vert.setUV(uv) 
        
 

I saw a uv scroller sometime before, But it only worked on A flat surface. Can you use this one on curved surfaces?

ok thanks Plant person:D

Damn, it don’t work…no i mean… i don’t know how to use it:o
Do i put the python in the Text editor and then name it like: Moving and then i go in the logic bricks of my plane and i put a controller : Python and then i write Moving in the little space and then…and then i don’t know:(
Could you put a little .Blend for me:o

oh and i’m not able to do copy/past in the text editor so it’s kinda long to write the hole thing…not the end of the world but it would be fun lol
:slight_smile:

oh and sorry i’m totally new to python but it seems that it’s a big + if you want to make game lol

Tony,

Here’s a demo .blend:
http://www.blendenzo.com/Files/Help/PepiusUVScrollScriptTest.blend

You probably didn’t add the property named “speed” to the object. If you examine the script, you’ll see the line that says

SPEED = own.speed

Read the first few lines of the script. “cont = GL.getCurrentController()” is assigning the Python controller that called the script (from the logic bricks) to the variable “cont”. “own = cont.getOwner()” is finding out what object owns the controller that called the script. In my example .blend, “own” refers to the plane with the cracked earth texture.

When the script says “SPEED = own.speed”, it is really saying “Read the property named speed that belongs to the owner of the python controller that called this script and assign it to the value named SPEED.” If the owner has no property named speed, then there will be no value for the script to read. If you check the terminal window (the Command console that also opens with Blender on Windows), you will see an error when you run the file without giving the object a property named “speed”. (The error will say something like “Attribute error: object has no attribute named speed”)

A couple of tips about the script:

  • If you set a negative speed, it will reverse the direction of the scrolling.
  • Change the line “uv[1] = uv[1] + SPEED” to read “uv[0] = uv[0] + SPEED” and see what happens. (It will technically accept the values 0, 1, and 2, which mean x-axis, y-axis, and z-axis respectively. Animation on the z-axis will do nothing for a plane, though.)To paste into Blender from an external clipboard, try [Ctrl}+[Shift]+[V] instead of just [Ctrl]+[V]. Blender has its own clipboard which is separate from the system clipboard. Similarly, use [Ctrl]+[Shift]+[C] to copy from Blender to the system keyboard. (These commands work on Windows, but they don’t work for me on Linux.)

Hope that helps.

-blendenzo

You should try Crystalspace if you are doing a 3rd person game.
You will be able to make very nice and detailed scenery to keep the players interest
Here is an install guied :
http://b2cs.delcorp.org/index.php/ArtistInstall

How is the Crystal Space thing going… As someone who tried to install it and gave up it would be nice to see some of the work people have done with it… to see what I’m missing

Anyone fancy doing this? maybe a new thread

Blendenzo: Nice thanks:D (and i’m sure it work this time lol)

And for Crystal Space i didn’t tried with the link of Mmph! but last week i tried to install it (downloaded it from another site) but it didn’t work so i hope it will that time

Larryboy:Yes maybe a new thread would be helpfull

What I posted here was completely off subject, so I removed it. Good luck tony.