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$
1
  • $\begingroup$ What sensor to you have running the script? It will run every time the sensor triggers it. $\endgroup$
    – sambler
    Commented Apr 27, 2017 at 5:24

1 Answer 1

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$
0

You must log in to answer this question.

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