5
$\begingroup$

I can't stop the rotation of the camera(around the z global axis), in BGE. The camera is set to dynamic. Here is part of the script, the only one that affects rotation.

def rotation():
    if (mX < 0.10) and (mY < 0.90):
        cam.setAngularVelocity([0, 0, 0.1], 0)
    elif (mX > 0.90) and (mY < 0.90):
        cam.setAngularVelocity([0, 0, -0.1], 0)
    else:       
        cam.setAngularVelocity([0, 0, -cam.getAngularVelocity().z], 0)
    #print (cam.position)
    print ("Angular Velocity :",cam.getAngularVelocity())

Setting the angular velocity to 0 does not work.So what I did was to subtract the current value(cam.getAngularVelocity().z). This kills the rotation but it is still slow and it creates a flickering effect.

I found 2 threads about this thing in other forums. They were unsolved. Any thoughts?

Here is the blend file

$\endgroup$
  • $\begingroup$ could you convert it to a static object? $\endgroup$ – Scalia Apr 28 '15 at 20:50
  • $\begingroup$ I do not want to, since I would not be able to use velocity no more.What's on your mind though? $\endgroup$ – Lev Apr 28 '15 at 20:58
2
$\begingroup$

This appears to be a reported bug

Workaround: use a very small value like 0.00000012

def rotation():
    if (mX < 0.10) and (mY < 0.90):
        cam.setAngularVelocity([0, 0, 0.1], 0)
    elif (mX > 0.90) and (mY < 0.90):
        cam.setAngularVelocity([0, 0, -0.1], 0)
    else:       
        cam.setAngularVelocity([0, 0, 0.00000012], 0)
$\endgroup$
  • $\begingroup$ Many thanks! That was it. I think this bug is for linear velocity also, but I fixed it with what you suggested. $\endgroup$ – Lev May 5 '15 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.