Limit motion copy on specific axes

Asked

Viewed 70 times

3

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 user vision.

I am using the following function to copy the 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 only on the X and Y axes by eliminating the Z-axis movement? Because my character floats in the scene when I look up.

FPS running https://www.youtube.com/watch?v=dzchFfIwtSQ

FPS with Oculus Rift https://www.youtube.com/watch?v=CwLc7XxRkr8

2 answers

0

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

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

Original:

It’s been (long) since I’ve touched Blender - but you’ve tried instead of :

mov2.worldOrientation = mov1.worldOrientation

Do:

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

?

0

Yes, I tried. It seems to me that the correct syntax for the function would be:

mov2.worldOrientation = [1.0, 1.0, 0.0]

where:

mov2.worldOrientation = [x, y, z]
  • but it’s not working

  • 2

    This should be a comment for jsbueno, no?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.