# adjustable animation speed help

this has probably been asked before but i couldnt find it easily

well im in the making of idea testing. One of them is going to be a walk cycle for a game im pulling together for fun, probably nothing past wip.

at any rate, the walk cycle is for a robot.

as you pilot the robot, the speed slowly increases and decreases.

since there is no set walk speed, and it varies, i need the animation to vary as well.

i got the calculations down already for max speed.

the robot in one stride of its legs (front to back of one leg). Is 8.5m/stride.

the max speed is 129.6km/hr. That would be in one hour a total of ~15,247 steps.

in one second that is 4.24 steps to reach that speed, or strides.

my question is, as the speed varies, i need the stride speed to vary as well. so if its only doing 10km/h, it would only be ~.37 strides per second.

i got the walk animation animated (very simple for the test).

how can i make the legs walk cycle, match the speed of the robot. im trying not to use python but instead logic bricks, but its looking that i might need to use python.

my current idea, is a keypress, moves a empty, that empty has a max/min. it reports the value to a property, so the property has the value, ie speed that the robot needs. Now how do i get that value to adjust the animation speed?

thanks for any help.

Hi,

you can use the action actuator in “property” mode. This mode expects the actual frame in a property set in the “Prop:” field. That can be a float or an int. Now you can set your own frame rate by increasing the property with each logic frame with a value that you calculate by the speed of the robot.

Examples:

default speed: increase the property by 1.0
slow speed: increase the property by 0.37234
high speeeeeeeeeed: increase the property by 3.534219686476235234245464

I hope this helps

thats what i was thinking, the only question i have is. Since its a walking and loops. is it going to stop at a given frame?

ie:

it takes 25frames to do one stride

if the property is 25 also, will the animation still loop or will it stay at 25?

well i tried doing property action that you recommended but much like i thought, it made the animation stay in one spot.

Currently i think the only way to do this is via python.

im reading and got the document of the python api and all the definitions but im now stuck

been following the tutorials abit, but im no python coder and is going to take me tons of time, which i dont mind but i oddly find no where on the net about examples for action api via python or how to implement ipo via python. Yet i know they exist somewhere.

right now im just looking for the code to get what i need, i guess my mind is just jelly right now

so im using python to simply spit out info via console in blender right now, doing the simple armature.get() and printing the name

in my action/ipo setting, im looking to get the ipo quatx out of the armature/bone, or the scale of the action (how many frames the action takes). but im just getting nowhere.

any links to tutorials on this other than the python api document?

no one? hmmm

i know its possible in python, but ive literally been through all tutorials i can find regarding either ipo action and or nla python and nothing has dealt this before. it seems like variable speed isnt that popular for walk cycles.

the problem i have is that everytime i try to use the getpoints or other style via python i always get a error.

the math is already all done. I just need to grab the point on a ipo curve, and scale it down.

or i have seen in several examples use the frame modifier and it be in the python api doc, but again nothing. Any one got links to python ipo stuff besides the api doc?

post blend, hard to understand your “letters”

Hello,

I’m not that sure what you want to do. But for an animation with variable speed I prepared you a blend file. It demonstrate how to set up the logic bricks without python.

You can use it and just set the property “stepsize” to the value that you need. As far as I understand you, you already know the speed. So it should be easy to set the right “stepsize”.

I hope it helps

### Attachments

variable animation speed.blend (172 KB)

Monster that was genius, everything i tried with logic bricks failed. And i wasnt getting much luck with python (mainly cause i was doing tutorials and probably would have taken many more hours learning python, something i have to do very soon)

the stepsize, and interval property is where i was going wrong.

ill be able to adapt and change your bricks to what i need so i can get a more fluid stepsize than preset numbers.

man i couldnt say thank you enough, so i guess ill just have to say one big thanks. and ill post a sample blend here to show you how much you helped me when i adjust it for what i needed.

well as promised here is a little test blend for the mech in my game

it has simple foward and stop, mainly because the other things are being worked on in python file so i can use it across mechs, but if not this was really easy to do and only took a few minutes

the code might be a little crude but for the math im using for other stuff this is as simple as i think i can get it for now.

thanks monster enjoy the little foward stop test file of what your help did for me

http://cid-729d84a103c4a44d.skydrive.live.com/self.aspx/Shared%20Modeling%20Stuff/locust1.blend

Hi elitewolverine,

I just wanted to know if you managed to animate your robot with python. I have a similar goal as yours, just wanted to start with the simplest setup (a 3 link arm) but haven’t been able to move anything. I need to move individual bones inside an armature with python within the gameEngine. I’m also a beginner in Blender and Python so any help will be appreciated.

Apollo
(working with Python2.5, Blender 2.49a)

i would suggest upgrading to 2.6 and 2.5 respectively because the new python stuff in the next release of blender is going to make 2.49a blenderpython not backwards compatible for certain functions etc.

and ive gotten a tad to work in the python/blender bricks. download my sample file in the post above you and take a look.

my hopes is to make a move.py script and thats what im slowly working on. my other things im currently working on is. Laser beam for my weapon, missles with particle effects and tracking/homing to hit a target. so ive put my animation abit to the side.

sorry it took me long to respond, if you have a specific question that your having a issue with just ask, me or another should be able to help like monster did with me

Hi.

I’ve had this buzzing round my head for a while and I finally got the inspiration to implement it.

Hope you don’t mind, but I used your posted .blend as a basis for the implementation.

VariableWalkCycle_locust1.blend (87.4 KB)

The robot has a force applied to the “main” empty. The action is controlled by the script. It reads the linear velocity of the “main” object and uses this velocity to calculate the ani_var property of the armature. ani_var is in turn used to increment the frame of the action.

getLinearVelocity()[1] is the velocity on the local y axis.

I use “velocity = -getLinearVelocity()[1]” with the negative sign because the robot is moving along it’s local negative y axis when moving forwards.

For calibrating the script you need just 2 variables. The number of frames in the walk cycle and the distance travelled in one complete cycle. Both these values can be taken directly from the action.

Once again, hope you don’t mind my using your .blend and I hope this gives you some inspiration as to how you could use Python for this. You can see that the logic brick setup is far simpler, but you need to understand a little Python.

Good luck for any games you make.