Getting horizontal mouse movement and playing an animation

Does anyone have a handy way to trigger an animation based on horizontal mouse movement? Is it possible to differentiate between left and right movement?

yeah, just grab a copy of simple mouse

have a value that is slowly erroded and add the change in x to it,

so if its negative, that means moving left, if its positive that means moving right

I could whip you up somehting if I get a minute tommorow,

I appreciate the help, however I need a solution that does not require me to change my whole mouse mechanic. Any idea how to do this through python?

you don’t need to use my mouselook for your system, just to gather the property,

the way I do it is to compare the mouse position between frames before it is reset back to center.

this value is then added to the mouse axis,

the script ‘Generate mouse’ should have what you need. (you may need to cut out some of the fat)


import bge


from mathutils import Vector
def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner
    Mouse = cont.sensors['Mouse']
    x = bge.render.getWindowWidth() // 2
    y = bge.render.getWindowHeight() // 2
    ctrl = cont.sensors['Ctrl']
    
    if 'init' not in own:
        bge.render.setMousePosition=(x,y)
        own['init']=True
        
    else:
        if ctrl.positive:    
            own['x'] += (x-Mouse.position[0])*own['Sensitivity']
            own['y'] += (y-Mouse.position[1])*own['Sensitivity']
            if own['x']>own['MaxX']:
                own['x']=own['MaxX']
            else:
                if own['x']<own['MinX']:
                    own['x']=own['MinX']
            if own['y']>own['MaxY']:
                own['y']=own['MaxY']
            else:
                if own['y']<own['MinY']:
                    own['y']=own['MinY']        
            ##bge.render.setMousePosition(bge.render.getWindowWidth()/2,bge.render.getWindowHeight()/2)
            if 'Count' not in own:
                own['Count']=0
            if own['Count']<10:
                own['x']=0
                own['y']=0
                own['Count']+=1    
            if type(own['Target']) is str:
                own['Target']=bge.logic.getCurrentScene().objects[own['Target']]
                own['Target']['MouseOwn']=own
            else:
                own['Target']['x']=own['x']
                own['Target']['y']=own['y']          
        
main()




I see, well in that case I will examine this and give it a shot. Thank you