I am attempting to “LOCK the Z axis” of a series of instanced objects in the game.
So essentially they all rotate on their local Z axis to face the player.
This is what I have currently, but the Object instances that run this code rotate on the global Z axis rather than their individual local Z axis–
from bge import logic
from mathutils import Vector
cont = logic.getCurrentController()
own = cont.owner
own_x = own.localPosition - own.scene.active_camera.worldPosition
own_y = own.localPosition - own.scene.active_camera.worldPosition
own_z = own.localOrientation.to_euler() - own.scene.active_camera.localOrientation.to_euler()
own_z = own.worldOrientation * own.localOrientation
world_y = own.scene.active_camera.worldPosition
own.alignAxisToVect((own_x, own_y, 0), 0, 1.0)
Here is my sample blend of the scene:2.5_Dimensions_FOR_TREES.blend (731.8 KB)