Automatic Animation

Hello! It’s me again!
I know that there’s a rag doll setup in this forum, and there’s also progranimals. Both deal with animation in a very high level!
So, for me, I need to have access to the armature bones, and do with them what I want, rotate in most cases, restrict, track, etc. What I know could work is:
To do the animation programming with proxy boxes and copy the position/orientation to the bones. This is when the first question came in. My API search gave me no results in accessing the bones from the BGE, or … did I forget?

The end result would be functions defining movement (e.i.:def walk(speed): ) the function might have actions, frames and speed controls.

Thank you for your support!

You can check the actionActuator’s setChannel().

I do not think it is worth for a walk cycle.

If you want different play rates (speed) just use the property mode of the action actuator. See Play Rate of the Action actuator.

If you want a complete set of actions for easy setup have a look into the WIP: Bit of Magic. With that you can setup your actions in one configuration file together with length, speed and direction.
You play the animation by setting a property (or sending a message I can’t remember).

The only thing you have to do is to add the character movement.

You can check the actionActuator’s setChannel().

Yes indeed, that will help me use and mix actions: must Check!

If you want different play rates (speed) just use the property mode of the action actuator. See Play Rate of the Action actuator.

Yes I know of that, I’ll most likely use it anyways.

I do not think it is worth for a walk cycle.

Well, yeah… I want to have python animation or at least python controlled…

When I started with blender, I made a FK character and used IPO to animate and properties to animate the character. For instance the legs will animate from their max to their min, then I’ll play the necessary frames for the walk and the ones for the run, all with the same animation.I want to do that with one single action as well. With actions, the same action cannot be reused, and I don’t want to do it the logic bricks way (since I’m learning to do almost everything with python).

Also, I want the player to have feet and hand align with surfaces (not mandatory, but cool nonetheless).

If you want a complete set of actions for easy setup have a look into the WIP: Bit of Magic. With that you can setup your actions in one configuration file together with length, speed and direction.

Will check on that later, I don’t have access to mediafire from here!
Thank you Monster.

It is manageable but it is hard to do.

I saw one or two threads regarding feet alignment some years ago. I can’t remember exactly, but I think multiple actions were used.

Keep in mind: running is not fast walking.
Walking and running are to different motions.
(compared to humans: children are not small adults ;))

Good luck with that.

Keep in mind: running is not fast walking.

You are right! However, in animation, there are walking frames in the running animation… but that’s not the point. When I mention animation, it was just a part of it. I wanted to say to a bone to rotate a few degrees in a period of time… and stuff like that!

Actually, a Run Animation could be achieved by practically exaggerating a Walk Animation. Technically it is the same, only that you swing your Legs far wider and the Hopping also increases. but the Base of both Animations is the same – like Child and Adult are basically both Human Beings. :stuck_out_tongue:

I personally love the Idea – also had it, but I never did it. Actually, Blender provides the F-Curve Window and there we see the Animations practically as Functions. Particularly for Cycles but also for experimental/abstract Animations it would be an interesting Thought to define for Example several simple Sin/Cos Functions for both Legs’ two Bones and the Feet.

Edit:
It is no Bone Animation etc., but I have my Project’s first Boss hoverin’ up and down with a Sine Function in its Script and several Outlines and itself are also rotating due to several Sine Functions. I just love that sort of Animation! :3

Yes, that is what I though, if I could manually define many “fake actions”, and probably mix them to get different animations… well that would be very cool!
@ C.A.ligári: Sine functions can be a very cool addition, if I learn how to use it!

So far, this is all I found on armature bones…officially!

class bge.types.BL_ArmatureBone(PyObjectPlus)
Proxy to Blender bone structure. All fields are read-only and comply to RNA names. All space attribute correspond to the rest pose.

name
bone name.

Type : string
connected
true when the bone head is struck to the parent’s tail.

Type : boolean
hinge
true when bone doesn’t inherit rotation or scale from parent bone.

Type : boolean
inherit_scale
true when bone inherits scaling from parent bone.

Type : boolean
bbone_segments
number of B-bone segments.

Type : integer
roll
bone rotation around head-tail axis.

Type : float
head
location of head end of the bone in parent bone space.

Type : vector [x, y, z]
tail
location of head end of the bone in parent bone space.

Type : vector [x, y, z]
length
bone length.

Type : float
arm_head
location of head end of the bone in armature space.

Type : vector [x, y, z]
arm_tail
location of tail end of the bone in armature space.

Type : vector [x, y, z]
arm_mat
matrix of the bone head in armature space.

Type : matrix [4][4]
Note This matrix has no scale part.
bone_mat
rotation matrix of the bone in parent bone space.

Type : matrix [3][3]
parent
parent bone, or None for root bone.

Type : BL_ArmatureBone
children
list of bone’s children.

Type : list of BL_ArmatureBone

Without examples, it’s very hard to use…

“All fields are read-only” and “All space attribute correspond to the rest pose” make it pretty useless for Your use (or any use I can think off).

The way to do this I think is to parent the bones to collision boxes - then move/apply force and torque to the collision boxes. I suggest You download some of the skinned rag-doll examples that have been floating around and look in to how they done it.

Interesting project… It’s on my ‘wish to do’ list too :slight_smile:

I think you’re looking at the wrong API section for what you want. What you would like is to be able to dynamically set the rotation of individual bones in your objects, right? Check out the BL_ArmatureChannel() section of the page.

There, you’ll find capability to manually rotate bones by Python code. Be sure to set the bone channel’s rotation_mode to PCHAN_ROT_XYZ, or 1, to be able to rotate the bone using Euler values (x, y, and z) using the channel’s rotation_mode variable. Also, update the armature (armature.update()) at the end of it to see the effect.

search in this path:

print (ob.channels [“Bone.004”])
print (dir (ob.channels [“Bone.004”]))
print (ob.channels [“Bone.004”]. pose_matrix)

warning, is full of bug

This might be a discussion for the animation forum. Even if it looks like a similar motion, it is different. You can verify that at the wikipedia bipedalism and wikipedia walking.
But I agree it might be possible to get an acceptable transition by mixing walking and running animations together.

I thought with 2.6 there should be an improved animation system that allows dynamic action mixing?

@Monster - If you’re talking about the BGE, Moguri’s Pepper branch (merging) was done awhile ago, so 2.6 does have animation improvements.

Good to know, let’s give it a try.

print (ob.channels [“Bone.004”])
print (dir (ob.channels [“Bone.004”]))
print (ob.channels [“Bone.004”]. pose_matrix)

Very nice of you, till now I’ve been asking how exactly do I have access to individual bones, my syntax is incorrect.
Would you mind providing me with the “types.BL_Armature” part? Thank you!

I think you’re looking at the wrong API section for what you want. What you would like is to be able to dynamically set the rotation of individual bones in your objects, right?

Hmm, indeed! I still get very little useful information. See, it the API, some simple functions come with a nice example, and clear description of how the code can be added. But here, the info is vague and not very helpful to beginners!

I suggest You download some of the skinned rag-doll examples that have been floating around and look in to how they done it.

Yes, that’s the plan! I remember downloading such an example long ago, but can’t find anything now… wraag’s setup is very dense, I can’t find what I need in there!
I’ll keep digging, thanks for all your help guys!

actually - regarding the walk - run animation thing, you cannot achieve a run by ‘exagerating’ a walk. There is much difference between the two. In walking, at least one foot is on the ground at all times. With running, both feet come off of the ground.

regarding feet clipping - I have this in my game, but i’d rather not reveal how I do it.

regarding feet clipping - I have this in my game, but i’d rather not reveal how I do it.

Don’t worry, right now I’m just trying to move the bones using a script, the aim being to control animations in a context (calculated animation) way rather than arbitrary(pre-made animation).

actually - regarding the walk - run animation thing, you cannot achieve a run by ‘exagerating’ a walk. There is much difference between the two. In walking, at least one foot is on the ground at all times. With running, both feet come off of the ground.

That is true, running is more like fast leaps, and walking, well, it’s walking. However, the legs movement is basically the same. From a running animation, walking frames can be extracted. But well, the point was not that, but rather being able to modify one animation to achieve others.

hi!:wink:

should be this
GameTypes.BL_ArmatureChannel

in my code first were some wrong spaces
this is right

import bge
c=bge.logic.getCurrentController()
ob=c.owner

print(dir(ob.channels[“Bone.001”]))

agree, also the times are different (loading and unloading of the force)