I’m very new to the game engine and i’m trying to code a very simple game demo atm. I want the object to continuously rotate to the left (along the y axis) as long as the A key is pressed (until it reaches a constraint, let’s say 50°), and when the key is released, the object should slowly return to the original positon. How do I do that?
Create a rotational action.
Play the action with an action actuator in flipper mode
Other way would be to subtract when a is not pressed as long as the rotation is bigger than the original rotation:
if not a.positive and object.worldOrientation.to_euler() > 0: object.worldOrientation.to_euler() -= 5
I did not try this out but it should work,
thank you very much! basically, it works. but somehow the object always seems to rotate around the global y-axis and not the local one, which is a problem because when i rotate the character in-game, the rotation is all messed up.
Change worldOrientation to localOrientation.