How can I rotate an object smoothly using sin or cos? I have an object in the center that "points" to objects around it. I wish to be able to click left or right buttons on the keyboard and have the object rotate (visibly, slowly, and smoothly) exactly 36 degrees using python.

How can I do this? I've seen stuff with sine or cosine and elapsed time but nothing that I can understand well enough to adapt to my needs.

I had this working using Action Actuators and since I want to be able to rotate clockwise and counterclockwise to point to 10 different objects, there were 21 different actuators. I would like to learn to do this with python instead.

Thank you,
Zach
Following solution might work for you (if I understand the requirement correctly) ...


Create a maxRot (int) property on the object.
Create an always sensor on the object that points to following python code



import bge
from bge import logic

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

if (own['maxRot']&gt;0):
    own.applyRotation ((0, 0, 0.0174533), True)
    own['maxRot'] -= 1




Create an keyboard sensor (right arrow) on the object that points to following python code ...



import bge
from bge import logic

cont = logic.getCurrentController()
own = cont.owner
own['maxRot'] += 36



Run play and click the right arrow.

[0.0174533 = 1 deg in radians]