1
$\begingroup$

I know you can lock rotation, but not in-game. Is there a python for it, or a special edit or something. Please explain. Please be specific. Thanks!

$\endgroup$
3
  • 1
    $\begingroup$ Could you please put more effort into this question, e.g. add that this is a follow up of blender.stackexchange.com/questions/4905/… and give more context. $\endgroup$
    – stacker
    Commented Nov 16, 2013 at 20:31
  • 3
    $\begingroup$ Is this for physics or animation? local or global axis locking? this question does not give enough info. $\endgroup$
    – ideasman42
    Commented Nov 16, 2013 at 20:42
  • $\begingroup$ It's very difficult to tell what you're asking, and it seems like you didn't make much effort to craft a well-asked question. Please improve it, or it will be closed. $\endgroup$
    – Matt
    Commented Mar 13, 2014 at 2:58

1 Answer 1

1
$\begingroup$

I understand the question as follows: You want an object's rotation to be locked in game engine runtime.

Here's how I would solve the problem.

(1). Choose the object you want to work with. The freezing will only work on that object with this solution.

(2). Go to the logic editor and make a Property sensor of type Boolean. It shall be named "Perm". Activate pulse triggering and set the frequency to 0.

(3). Create a game property of type "Boolean" named "Lock" that is initially set to false.

(4). Make a "python" type controller in the logic editor and connect it to the Boolean sensor Perm. It shall be named "LockXYZ"

(5). Make a sensor of your choice that will set the boolean to true when you want the object's rotation to freeze. The sensor shall be named "Atog"

(6). Create a Property actuator that connects to Atog. This actuator will set Perm to "True".

(7). Open the text editor and create a new text called "LockScriptXYZ.py"

Paste the following in "LockScriptXYZ.py":

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

own.worldAngularVelocity.x = 0.0
own.worldAngularVelocity.y = 0.0
own.worldAngularVelocity.z = 0.0

(8). Choose the script "LockScriptXYZ.py" for the python controller "LockXYZ"

That should do it.

I don't know if this was what you were looking for, but at least it's specific.

$\endgroup$
0

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