Setting the Object.position

Is it possible to move an object by script and without any actuators?

My scene has two objects: an empty named ‘e’ and a cube named ‘Cube’. The empty has an always sensor (positive triggered) which calls the following script:

import GameLogic
from math import sin

scene = GameLogic.getCurrentScene()
Cube = scene.objects["OBCube"]
e = scene.objects["OBe"]

def z(amplitude, frequency, time):
    return amplitude * sin(6.283185*frequency*time)

# Empty has a timer property time
time = e.time

# Cube.amplitude = 7.500
# Cube.frequency = 0.750

z = z(Cube.amplitude, Cube.frequency, time)
Cube.worldPosition[2] = z

print 'time =', time
print 'z(t) =', z
print 'pos =', Cube.worldPosition
print ;

And here is what i was trying to do:

  • ask the empty what time is it
  • calculate new z coordinate z(amplitude, frequency, time)
  • set new z coordinate to the Cube object’s global position [x, y, z]
    The Cube has float amplitude and float frequency. An additional object could have different values in these properties. Using Cube.localPosition[2] did not work either.

I think i know how to move that box, but why dont it move this way?

http://img718.imageshack.us/img718/6669/setposition.png