Actions in armature

Hi everybody! I have an armature:

 bge.logic.getCurrentScene().objects["Armature"]

How can I to know the actions that it have? Example I have an action that I load with

 bge.logic.getCurrentScene().objects["Armature"].playAction("Run",9,32,play_mode=1)

I saw this. And I tried this

print(bge.logic.getCurrentScene().objects["Armature"].channels)
print(bge.logic.getCurrentScene().objects["Armature"].constraints)

But the first print the bones of armatures and the second the constraints. There is any way to know the actions that my armature has?

Your armature ussually does not have actions, his Ik targets do,

in the armature you have

always -------------and----------------Run armature

and then have triggered actions on the Ik targets

Then this how check if the action is correct? I play action without logic brick so i haven’t always -------------and----------------Run armature

you do not know :frowning:

When put in playaction a incorrect name the console show “Failed to load action: Action”, (Action=name our action). So I look source code and I am coming to search “Falied to load” for to know where is done the comprobation if action is correct but I don’t find result
And I found this that seem the playaction function

KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
    "playAction(name, start_frame, end_frame, layer=0, priority=0 blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0)
"
    "Plays an action
")
{
    const char* name;
    float start, end, blendin=0.f, speed=1.f, layer_weight=0.f;
    short layer=0, priority=0;
    short ipo_flags=0;
    short play_mode=0;

    static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "priority", "blendin", "play_mode", "layer_weight", "ipo_flags", "speed", NULL};

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhfhf:playAction", const_cast<char**>(kwlist),
                                    &name, &start, &end, &layer, &priority, &blendin, &play_mode, &layer_weight, &ipo_flags, &speed))
        return NULL;

    layer_check(layer, "playAction");

    if (play_mode < 0 || play_mode > BL_Action::ACT_MODE_MAX)
    {
        printf("KX_GameObject.playAction(): given play_mode (%d) is out of range (0 - %d), setting to ACT_MODE_PLAY", play_mode, BL_Action::ACT_MODE_MAX-1);
        play_mode = BL_Action::ACT_MODE_MAX;
    }

    if (layer_weight < 0.f || layer_weight > 1.f)
    {
        printf("KX_GameObject.playAction(): given layer_weight (%f) is out of range (0.0 - 1.0), setting to 0.0", layer_weight);
        layer_weight = 0.f;
    }

    PlayAction(name, start, end, layer, priority, blendin, play_mode, layer_weight, ipo_flags, speed);

    Py_RETURN_NONE;
}

I believe that

layer_check(layer, "playAction");

is the function, but “playAction” isn’t variable. Maybe this function is that I search, but I don’t know where is his code

if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhfhf:playAction", const_cast<char**>(kwlist),
                                    &name, &start, &end, &layer, &priority, &blendin, &play_mode, &layer_weight, &ipo_flags, &speed))
        return NULL;

Maybe if I find where it’s done the comprobation I can add a function to KX_GameObject

The currently assigned actions is only known to Blender (bpy) not the game engine. This is because the BGE is used to use the actionActuator to play actions. And the actionActuator has the necessary parameters (action name, start, end) set up in its configuration.

What I do to dynamically configure the ActionActuator is to keep these configuration parameters in a python list. So I can read it from there and apply it the the actuator.

This method indeed assumes the action exists already. To ensure that (e.g. when linking groups) I have one object as part of the group with action actuators for each action to link. The actuators are not activated, they are just hooks to link the actions into the linking scene. They do not even needs to be part of the object that plays the actions (so it can be a plain empty).

Then I guess I will have to do a list manually for each character :S
But… then how load libload the actions? libload is bge and I can to do

 bge.logic.LibLoad("character.blend", "Scene",load_actions=True)

I will have to look the source code of libload for view how work.

Maybe can I do something so?

 print(bge.logic.expandPath("//Characters/soldier.blend/Action"))

or combined with os module? I will investigate

why use python for this?

what are you attempting to achieve?

loading actions from a file?

How if I did a 3d mugen or street fighter with community’s characters without I don’t known the movements of all characters

example

You should know the actions. If you do not know from beginning you could load an object that keeps the action names when you load the actions.