Problem with action Speed in Python

I am using a script to make my game character’s animation speed change dynamically based on the velocity that he is moving (basically, the walking speed increases as the character’s movement accelerates). Whenever I use the playaction() thing in my script to change the speed during runtime, the speed change actually only takes effect every WHOLE number interval, as if the speed input for playaction() is read as an ‘int’, even though the documentation says the speed input is a ‘float.’ Here is the part of my script that I am referring to:

if [character speed is greater than 0]:
    own.playAction('Walk', 0, 37, 0, 0, 3, 0, 0, 0, ([current character speed]/[max character speed]) )

Maybe this is a bug, but if anyone could help that would be great.

It’s not a bug, it has to do with Python. You’re not forcing the inputs to be floats, and so it will do integer-based division, as one, or both of the inputs are already integers, if I recall. Try

float(currentcharspeed) / float(maxcharspeed)

converting the variables to floats first, or setting them up as floats initially.

Hmm, it still doesn’t make a difference either way.

Actually, I just noticed something. The animation actually starts whenever the character’s acceleration is at its max. So basically the action doesn’t change its speed while the character’s velocity is changing. Wierd.

Ah, playAction triggers each time you run the function (i.e. constantly running playAction will make the armature ‘stall’ its animation at the first frame). Instead, play it once if it isn’t playing already and use setActionFrame() to set the play speed of the animation.

Thanks man, that seems to make sense now.