1
$\begingroup$

I'm using 'ApplyRotation' but the object does not stop spinning.

import bge
from bge import logic

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

for i in ranger(0, 100)
    owner.applyRotation([0,.02, 0], 1)
$\endgroup$
  • $\begingroup$ What sensor to you have running the script? It will run every time the sensor triggers it. $\endgroup$ – sambler Apr 27 '17 at 5:24
0
$\begingroup$

applyRotation is (like most operations in Python) a one time operation.

It applies the provided turn exactly once at the moment of calling.

When you discover a continuous turning it means you execute this operation multiple time.

When you can see the turning (=animation) you do apply the turns at different frames resulting in a turning animation (one frame = one step).

Your code applies a lot of small turns (steps) in one frame. This means you will only see the final orientation. As there should not be a problem in calculating this final operation your code is very inefficient and is wasting processing time.

Keep in mind:

  • Your code describes the behavior within a single frame.

To get the animated turning you execute the code at each frame when you want a turn step.

I'm using 'ApplyRotation' but the object does not stop spinning.

This sounds like you execute the code at each single frame (see sensor settings).

$\endgroup$

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.