Getting property from an object

Hallo!

I did a very small Arkanoid clone. For this I got a paddle which is mouse driven via a python script. Everything works fine.

This paddle is the parent of a cube called PositionCheck which moves exactly with the paddle. For the cube I defined a property “x” (float), which is permanently updated by a python script and an Always controller.



from GameLogic import *
from Rasterizer import *

Cont = getCurrentController()
Own = Cont.getOwner()

position = Own.getPosition()

Own.x = position[0]


This is working, and I can see the cube’s x-position via debug properties.

Question is: How do I read the cube’s property “x” from a python script which is linked to the paddle? (means getting the cube’s x-position from the paddle script)

Any ideas?

GreetZ

ReSeT

You could link the paddle script to an Always sensor on the cube. Then use some code like:

Cube = Cont.getSensor("Always Sensor").getOwner()

Own.x = Cube.x

O.K . figured it out and it works. Thank you!

:slight_smile: