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$
2
  • $\begingroup$ could you convert it to a static object? $\endgroup$
    – ruckus
    Apr 28, 2015 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, 2015 at 20:58

1 Answer 1

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$
1
  • $\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, 2015 at 13:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .