Servo Actuator Question

Is there any way to set the target linear velocity in python? I know there’s a method for setting the linear velocity, but that’s not what I want, and the API doesn’t seem to have any function for setting this unless I’m overlooking something.

Keep in mind that the servo control actuator is a derivate of the object actuator. It shares the same data member and methods to set the actuator parameters.
So to answer your question, yes there is a way: just use the setLinearVelocity() method of the actuator. In servo control mode it has the effect of setting the target linear velocity.

I see. Thanks.
I have another question about using python with the object actuator. I’m trying to constrain my character to just the x and z axis (like a 2d platformer) What’s wrong with using code like this? My character can’t jump anymore (To jump I apply a z velocity when you hit the jump button on another actuator.

 
import GameLogic
control = GameLogic.getCurrentController()
owner = control.getOwner()
act = control.getActuator("act")
speed = owner.getVelocity()
act.setLinearVelocity(speed[0],0,speed[2],False)
GameLogic.addActiveActuator(act,True)

This code is a bit awkward: you use the object’s linear velocity to set the target linear velocity. I see it as a dead lock: the speed is locked to whatever value it had at the begining.

Normal use of the servo control is to set the target speed to something and let the actuator obtain that speed. To jump, the best way is to apply a vertical impulse, this will cause the object to jump and loose contact with ground. Once in the air, the servo control should logically be disabled (use the ray sensor and the state system to disable the actuator automatically) because you cannot control your speed when you are jumping. The gravity will bring the object down and the ray sensor will reactivate the servo control.

To force y speed to 0, just set the Y target speed to 0 at all time and don’t setv any force limit on the Y axis: the servo control will apply full force to keep the Y speed to 0. This will not eliminate the possibility of a slow drift along the Y axis but you can set the Y position back to a fixed value at regular intervals to ensure 2D movements.

But I want to be able to control my speed while jumping. I want the player to still be able to move left and right on the x axis but not mess up the velocity on the z axis at the same time.

Never mind, I figured it out. Just have the z velocity set to 0 at all times and give it a sufficient max and min force value.