[ i have solved it ] i want use the mouse only left right movement

i want use the mouse only left right movement to run my player turn action, i don’t want my action run when mouse move up down.

my script:

import bge
GameLogic = bge.logic
from Rasterizer import *
    
cont = GameLogic.getCurrentController()
obj = cont.owner
mouseMove = cont.sensors["mouseMove"]
Sensitivity = 0.10
CenterY = getWindowHeight()//2
CenterX = getWindowWidth()//2

def turning():
    if mouseMove.positive:
            cont.activate("turn")
    else:
        cont.deactivate("turn")
            
turning()

Attachments

turn_test.blend (3.4 MB)


mouseMove.mouse.position.x is your friend.


import bge
GameLogic = bge.logic
from Rasterizer import *
    
cont = GameLogic.getCurrentController()
obj = cont.owner
turn = cont.actuactors['turn']
mouseMove = cont.sensors["mouseMove"]
Activate = 0
Position = abs(mouseMove.mouse.position.x)>.01:
    Activate=1

 if Activate==1:
            cont.activate("turn")
    else:
        cont.deactivate("turn")
## need code to return mouse to 0,0


untested and probably needs work

thank you @BluePrintRandom but your script not work.

Something like this? the code is ugly so you might want to change it around a bit.

turn.blend (466 KB)

it looks more like he is trying to engage a animation during mouse movement on x axis.

I did not really get it working for him though,

If he set the animation to loop end or play, it works, but it doesn’t stop when he finishes turning, only later!

thanks @scuba111223 but i want use the mouse only left right movement to run my player turn action not to turn the cube, see the attachment blendturn_test.blend (3.4 MB)

any other help please!

The blend I uploaded was to show you how you could do it, like i said its ugly and probably inefficient. Anyways, here you go, is that more or less what you want? you will probably need to disable your rot script to see if it works or not.

turn_test.blend (3.64 MB)

i have solved it.
script:

mouse = logic.mouse

mouse.position = (.5,.5)
MouseMove = cont.sensors["MouseMove"]

def mouseMove():
    mouse.position = (.5,.5)
    if MouseMove.positive:
        if mouse.position[0] > .55:
            cont.activate("turn_right")
            cont.activate("turn_action")
        elif mouse.position[0] < .45:
            cont.activate("turn_left")
            cont.activate("turn_action")
        else:
            cont.deactivate("turn_right")
            cont.deactivate("turn_left")
            cont.deactivate("turn_action")
            
mouseMove()

the blend:

Attachments

player_turn.blend (3.38 MB)

A useful resource for everyone!