hm… well this scripts should work I just modified it for the gameengine…Just link this to a sensor.
import GameLogic
strn = [0.00, 0.00, 0.00]
ob = GameLogic.getCurrentController().getOwner()
def randObjMove():
global ob
x = ob.getPosition()[0]
y = ob.getPosition()[1]
z = ob.getPosition()[2]
# This is just some crap to add the random addition to its current position
strRand = str(GameLogic.getRandomFloat())
strn[0] = str(x)
strn[1] = str(y)
strn[2] = str(z)
xstr = int(strn[0].find("."))
ystr = int(strn[1].find("."))
zstr = int(strn[2].find("."))
addx = strn[0][:xstr] + strRand[1:]
addy = strn[1][:ystr] + strRand[1:]
addz = strn[2][:zstr] + strRand[1:]
loc = (float(addx), float(addy), float(addz))
return ob.loc
ob.setPosition(randObjMove())
ACK!!! I am sooooo soryy lol I not alct returned the wrong this but also used the worng brakects!
import GameLogic
strn = [0.00, 0.00, 0.00]
ob = GameLogic.getCurrentController().getOwner()
def randObjMove():
global ob
x = ob.getPosition()[0]
y = ob.getPosition()[1]
z = ob.getPosition()[2]
# This is just some crap to add the random addition to its current position
strRand = str(GameLogic.getRandomFloat())
strn[0] = str(x)
strn[1] = str(y)
strn[2] = str(z)
xstr = int(strn[0].find("."))
ystr = int(strn[1].find("."))
zstr = int(strn[2].find("."))
addx = strn[0][:xstr] + strRand[1:]
addy = strn[1][:ystr] + strRand[1:]
addz = strn[2][:zstr] + strRand[1:]
loc = [float(addx), float(addy), float(addz)]
return loc
ob.setPosition(randObjMove())
The bad news is, I can’t tell that the object is moved at all from its default placement.
I was hoping that it would be at pointA one time, then at pointB the next time the game started up…so that the player got a different startup experience each time he/she played.
Strange, forbidden download when just click link. But I tried again with download accelerator, and it works. So someone want to use it, maybe i can upload it to my server. By the way, nice blend file
I copy the script into an existing project I have and it runs fine.
I copy the script into a new project and it gives the error regarding the init line. I even try to import the text from Ashid’s .blend, rnd.py, into the new project and it errors regarding the init.