I’m trying to rotate an object a 25 degrees when I hold down a button, then when I release the button, it rotates back to the starting point.
I’ve been trying to figure out this for a while now with no success. I’ve come to the assumption that I will need to do this with python script, but my knowledge of python is very basic and I know nothing of the blender specific properties, so I have not attempted it due to lack of knowledge.
Can someone help me out with this? I do know enough about the game engine to know how to call scripts in specific situations.
Herm… could an animation set on flipper do the trick? You rotate your object in the animation, an call it with an action actuator. If not, well, there is this great tutorial on Blender cookie on BGE python. http://cgcookie.com/blender/2011/09/22/introduction-to-scripting-in-the-blender-game-engine-part-01/
Add a keyboard sensor named “Rotate” and link it to a python controller associated to the following script:
from math import radians
objs = bge.logic.getCurrentScene().objects
obj = objs['Cube']
rotate25 = obj.sensors['Rotate']
if rotate25.positive == True:
obj.worldOrientation = [0., 0., radians(25)]
obj.worldOrientation = [0., 0., 0.]
Thankyou for that, that works perfectly