Max Linear Velocity Per Axis

I am not sure if it is possible, so I am asking it here - is it possible to set objects maximal linear velocity only per single axis? I want to limit objects velocity in X and Y axis, but leave the max velocity infinite(or very huge) in other axis.

while on the ground?

if ray.positive:
    if abs(own.localLinearVelocity.x)>5:
## if local lin velocity.x is more then 5, or less then -5, multiply by .95

Thanks! This is very useful!:slight_smile:

def test(cont):    
    own = cont.owner
    #allocate variables
    x = own.localLinearVelocity.x
    y = own.localLinearVelocity.y
    z = own.localLinearVelocity.z
    #print them
    print('X = ' +str(x)+ ' - Y = ' +str(y)+ ' - Z = ' +str(z))
    #increse the variables, or do whatever you want with it
    x += 1.0
    y += 2.0
    z += 3.0
    #set the variables
    own.localLinearVelocity = [x,y,z]