I have a cube that uses applyTorque to align itself to the camera, which rotates freely about the cube by mouse. This setup works okay, but I’d like to cover the cube’s range of motion with less rotation from the camera. Here’s my code so far:
import bge from mathutils import Vector cont = bge.logic.getCurrentController() obj = bge.logic.getCurrentScene().objects cam = obj["Camera"] own = cont.owner ownRot = own.worldOrientation.col axis = own.getVectTo(cam) quat = ownRot.rotation_difference(axis) vec = Vector(quat.to_euler()) #Rotation x2???? torque = 100*1 own.applyTorque(torque*vec,0)
For example, if the camera was rotated at 45 degrees from the cube, the cube would rotate to 180 degrees (straight up). if it was rotated -45 degrees from the cube, the cube would rotate to face straight down. Or if 0 degrees, then the cube’s rotation would also be 0.
Basically, I’m trying to get an output of vectors with angles 0-180, with inputs of only vectors with angles 45-135. The only problem is, multiplying the vector by 2 just makes it a longer vector - it doesn’t change the rotation at all.
Is there any way to multiply the rotation of a vector?
Thanks in advance!