Is possible change Speed animation with python?

I wish reduce Speed of animation of player with python
This is possible in runtime with python?
thanks.

i try with playAction and got error KX_ACTION_MODE_LOOP is not defined


if Key_W.positive or key_S.positive or key_A.positive or key_D.positive and  Key_Shift.positive == False and GlockActive == True and Message_Low_Speed.positive:
    # set action variables
    name = "Glock_Player_Walk"
    start = 0.0
    end = 40.0
    layer = 3
    priority = 2
    blendin = 1.0
    mode = KX_ACTION_MODE_LOOP
    layerWeight = 0.0
    ipoFlags = 1
    speed = 0.25


# play an action
    obj.playAction(name, start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speed)

I,m using loop stop but what i need is just change a speed from my animation of 1.0 to 0.25
i set mode = 1 #its loop
and got this error in console then
Failed to Load action: Glock_Player_Walk

anybody if possible help me

armature.scaling = 0.5

not really a clue if you can scale an armature(never tried it, but i’m sure it will work) but obj.scaling is the scaling command.
Or do you mean something else?

i need just scale key animation not armature object.There possible in action editor but i need scale in runtime.Need acess Action actuators may be in player rig object is only degree or increase delay time to execute animation need this.

i go try test speed may be can work like a scale fo action editor
http://bgepython.tutorialsforblender3d.com/Action/playAction

I remember someone telling me that resizing the rig directly affects animations because having a different scale messes up the pose space or something, but I don’t really know if it’s true. I parent the armature to another object and apply any transformations there, just to be on the safe side.

Scaling the animation itself as in pressing S in the dopesheet and making it longer, well, I don’t think that’s possible. But you can always make the action play slower.

I remember someone telling me that resizing the rig directly affects animations because having a different scale messes up the pose space or something

Yes true, if you key-frame the bone(s) position it will mess up the animations, but with normal animations rotation is enough to key-frame. And indeed using an empty or bounding box is better for it.

i go try test speed may be can work like a scale fo action editor
http://bgepython.tutorialsforblender…ion/playAction

What are you exactly trying to do/make?

change speed of animation undestand in action editor you can made this with scale incrising.

well for now i create a second animation like the first with 2X more frames(Scale 2X only:eyebrowlift:) and creating a properties boolean in armature player object can run 1 or another for get better result wth player walk sounds and movements in open world.Open world change many things of close world.I think may be logic bricks C language start working better now for work with animations.

I go stay this thread opened more one week and after if no get another alternative with python will stay with that.

Short answer - you can not scale the animation speed in bge with Python.
No “workarounds” really works in a game. Just get with it and make second animations all the way. :wink:

try either bge.logic.KX_ … or logic.KX_ …

Automatic playing

As far as I know, you can’t change the speed of a running animation.

With the action actuator you can’t even set the speed of the action (there is no according parameter).

With Python you can (as you did) set the speed when start playing the action. This means you do not need a second animation, but you play the same animation with different speed (after stopping the first animation indeed).

Explicit play logic

You can play the animation at any speed when you set the currently played pose explicit.

Via Actuator: use the property mode.
Via Python: use setActionFrame()

you should be able to speed up or slow down an animation if you run the animation based on a property…like the good old [‘anim_frames’] using ‘anim_frames’ for both min, max frame…then you can adjust the way you increment the anim frames…I have not tested this…and floats do work.

yes but animation is not easy when you work with scripts controlling actuators.python and C work as far as ocurr smal bugs lol

thank you will try test for see.

it’s really not that difficult…ofc there is always a learning curve when you do something new…or have not had a lot of experience in scripting…but as far as games go nearly all scripting languages have a similar behavior…as their intent is on the same thing(making games)…I really recommend you start getting your feet wet with coding…start small and as it becomes easier try more and different things…it will only make your creations better…and coding is generally more productive than bricks.

but do what you are comfortable with.

setActionFrame will set all anomations or can just own

Friend i think for me better work with change frame rate animation in render scene properties, level by level cause i work with no vsync understand then when frames reduce reduce more yet speed of animations.
In this case i will change speed of all animations right?

… change frame rate animation in render scene properties …

This means you set the playback speed before you even start the game. I understood your question you want ot change the playback speed on-the-fly while the animation is running.

btw. I do not see a relation to V-Sync. The playback speed is relative to real time (seconds).

why not just change the ‘speed’ variable in the animation function…by casting it to another variable

speedvar = x
obj.playAction(name, start, end, layer, priority, blendin, mode, layerWeight, ipoFlags, speedvar)

friend is not playback i,ve started another topic asking how change animation frame rate in runtime is default 24.I set 30 for level 1and 2 close world fine cause my avarage frame rate are 150 to 180 FPS.But for level 3 open world reduced to 110 120 FPS max with no vsync no use frame rate then i need set to 60 before start level 3 understand? Its normal but bge have pyhon code or function for that?
thanks