python – Limit motion copy on specific axes


I'm developing a game in Blender and programming in Python. I had to develop solutions to work with oculus rift. Where my character follows the movement of the user's vision.

I'm using the following function to copy camera movement to the character:

import bge

def main():
    scene = bge.logic.getCurrentScene()

    mov1 = scene.objects["Camera"]
    mov2 = scene.objects["Cube"]

    mov2.worldOrientation = mov1.worldOrientation

How do I limit the copy movement of mov2 to only the X and Y axes eliminating the Z axis movement? Because my character floats in the scene when I look up.

FPS working

FPS with oculus rift


Update : If the property is a sequence of three elements, just replicate the first two and force the third to zero:

mov2.worldOrientation = [mov1.worldOrientation[0], mov1.worldOrientation[1], 0]

Original :

I haven't touched Blender in (a long) time – but have you tried it instead:

mov2.worldOrientation = mov1.worldOrientation


mov2.worldOrientation.x = mov1.worldOrientation.x
mov2.worldOrientation.y = mov1.worldOrientation.y


Scroll to Top