slow motion animation error

okay this is hard to phrase eloquently.

I have an animation set up on the property actuator which i call “timeline”
then i have an actuator constantly adding to that property called “speed”

speed normally equals 0.4 which makes it run at normal pace but when I want to slow the animation down i make it equal 0.1. this makes the animation frames creep by and give the appearance of slow motion.

so my problem is if the current animation starts at frame 1 and ends at frame 46

i want the “speed” to = 0.4 until frame 20, switch to 0.1 until frame 30, then switch back to 0.4.

how i tried this was basically

if own[‘timeline’] > 19 and own[‘timeline’] < 31:
speed.value = 0.1

the issue is that since I wrote it like that the animation stops at frame 31. not 46. even though earlier in the script it tells the animation not to stop until 46.
why does it over ride the end frame. If you have a different way to get the result let me know. :no:

I think you’ll have to post the whole script to really get help - there’s more to it than just those two lines.

yeah… the problem is there is information in the scripts that don’t pertain to this particular question but you guys aren’t stupid so i’ll post some stills

I suggest to adjust the keyframes of the animation to make it play at constant rate.
Or break it into smaller actions

Anyway if you really need that:

def calcSpeed(timeline):
  if timeline &gt; 29 : 
    return 0.1
  if timeline &gt;19  : 
    return 0.4
  return 0.1

alright I am going to try and explain this with pictures. this code is for the camera rig. wish me luck.
the picture above shows the code that makes the current animation i want to play, well play. the top, left, right etc is the direction the attack is coming from. so when top is positive then play the top attack animation at the speed of “x” (because the animation actuator is a property actuator.
this picture shows the logic attached to the camera. the “speed” actuator is always adding 0.0 to the timeline property which controls the amount of frames in the animations i want to play. the below picture will later change the 0.0 value to 0.1 for slow speed.
this picture shows the code in the last stable form I had it in. so if the player gets attacked from the top then x equals 45"frames"
the earlier script will activate the action property actuator and make the speed actuator = 0.4 so the timeline property will constantly add 0.4 to itself making the animation run at the desired rate for normal speed.
If the timeline property ends up having a greater number than X it will revert to zero. speed will revert to zero. and the animation actuator will be deactivated.

Now to the point. the last section of code in the above picture shows that when the timeline float > x/2 (IE, makes it to the halfway mark of the animation) the speed actuator will change to 0.1 and the animation will slow way down. so the animation starts fast then slows down halfway through. yay for me.
so finally the above picture illustrates what I want the code to look like. the last section has been changed to make the animation play until frame 20 at normal speed, change to slow motion until frame 30 and then revert to normal speed until the animation finishes.
I know i haven’t given it a reason to revert back to normal speed yet.
but the problem lies in that when I write it this way the animation stops at frame 31 instead of finishing all the way to frame 46.
what am I doing incorrectly?

I’m sorry I am not a skilled coder. I’m not quite sure what I’m looking at. I know you’re defining your own function but exactly how does it work?

oh I figured it out. once i added

elif dir == “top_attack” and own[‘timeline’] > 29:
speed.value = “0.4”

it worked. wow that was a lot of wasted effort

Just for information:

The function returns you the speed according to the timeline provided.
You use it this way:

speed = calcSpeed(timeline)

I choose a function because this one-line statement is much better readable than having all this conditions in a large block of code.

uhm… there many thing for improve your script …

but…this is not Blender 2.6!

I see property mode at work!