character rotation?

How can i get a character to rotate, without the motion actuator. I mean it’s good, but i need something else. I am rotating a characters back so that he will turn. But in game engine I can’t press left arrow to turn some frames to the left then rotate some or all frames right smoothly with the right arrow.

Try animations.

Are you sure? I mean I thought it was a game logic problem.

You can use python script to read the input


# Gather the objects we need.
cont = bge.logic.getCurrentController()  # Get our logic controller.
obj = cont.owner                               # Get our physics object.
keyboard = bge.logic.keyboard            # Get the keyboard.
scene = bge.logic.getCurrentScene()     # Get the current scene.

rotSpeed = 0.1 # Rate (speed) of rotation.

if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.LEFTARROWKEY]:
    #rotate left
    obj.applyRotation((0, 0, rotSpeed), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.RIGHTARROWKEY]:
    #rotate right
    obj.applyRotation((0, 0, -rotSpeed), True)


Then noodle an always sensor to the pyton controller. I’m not sure if that’s what you are looking to do or not.

rather than that, Dear sir, Would you teach me a Python script that allows the mouse to control the rotations of a single armature (it’s only object in game per say)


import bge

# Gather the objects we need.
cont = bge.logic.getCurrentController()     # Get our logic controller.
obj = cont.owner                            # Get our physics object.
keyboard = bge.logic.keyboard               # Get the keyboard.
mouse = bge.logic.mouse                     # Get the keyboard.
scene = bge.logic.getCurrentScene()         # Get the current scene.

rotScaler = 1       # Rate (speed) of rotation.
minMouse = 1        # Minimum mouse movement allowed before sensed.

# Get the current mouse position.
currentPos = mouse.position

if not "lastPos" in obj:
    obj["lastPos"] = currentPos

# Determine the movement of the mouse, adjust for the scaler.
deltax = (currentPos[0] - obj["lastPos"][0]) * rotScaler
deltay = (currentPos[1] - obj["lastPos"][1]) * rotScaler

# if (abs(deltax) >= minMouse):
obj.applyRotation((0, 0, deltax), True)
# if (abs(deltay) >= minMouse):
obj.applyRotation((0, deltay, 0), True)

# Update mouse position.
obj["lastPos"] = currentPos

wow, thanks. Although i tried the it similar to that but on location, can you teach me that as well?