# How to move an object in to the corresponding mirrored coordinate? (Asteroids Clone)

Hello Blender Artists Friends! I have a question for you!

Suppose I have character surrounded by a cubic room.
My goal is to move that character to the opposite position of the room every time the character reaches one of the walls (roof and floor included).

Like in the classical game “Asteroids” but with the Z axis included.

It’s already possible to print the position by using a game property (string) attached to this module:

``````    def update(cont):
own = cont.owner

own["pos"] = str([round(v) for v in own.worldPosition])
``````

But how do I create the interval able to move the character object to the desired position?

There is a .blend prototype hosted HERE.

Thank you!!!

There is another prototype that can be found here:

For this second prototype if you press only the “W” key continuously, the character will move to the opposite side as intended. But… How does one achieves the integration?

So in THEORY (i did not test this)
you can just save the global coordinates into a variable.

var = own.worldPosition

now you can recall the 3 variables (x,y,z) with var[0-2]
next you just do something like :

if int(var[0]) > 50
var[0] = 0
own.worldPosition = var

This should work, but it only works with global coordinates

You can also create 6 Cubes for each side of the wall and connect them with the “player cube” logic bricks. Each time the player collides with one of the walls you “move” the player cube to the other side.
Of cause you need to know the distance, but this also works dynamically

I support Blackwood111’s idea with a modification.

You add an offset to the according coordinate.

For example: Collision with +X plane -> add -100BU to X, coordinate

You do not even need python to do that, just six sensors with six motion actuators with dLoc set. Ensure the added offset does not place the object right into the opposite wall (should be a bit smaller than the dimension of the cube.

While I write that I think one object with six materials (for each site) might be fine too.