I’m setting up a character. I’ve got two actions created, clapping its hands, and waving its hands. I want to put them so I can control which action is being done, with a joystick on an Xbox360 controller. I’ve got the controller connected and working. I’ve tested that I’ve got the joystick commands correct with a simple change of location command.
Now, when I move the joystick up and down, I want the character to wave. When I move the joystick right and left, I want the character to clap. And using the playAction command along with the feedback from the joystick, I have been able to control the playAction expressively, so I can control how fast it moves from one end to the other of the action with the joystick, rather than just cueing the action and waiting for it to finish. I can also go backwards through the action.
I created two actions, and I can run either of them but not both. I tried running them with both in a single python script, and running them from two python scripts, one with each motion. I watched a couple of youtube tutorials on combining actions but they didn’t seem to address my situation.
Is there a difference in how the actions can be handled if they are frozen in the NLA editor? I just created them in the Action editor and call them in the python code.
I also tried using setActionFrame(). I just got errors. Are you supposed to initialize the action with a playAction, and then in later loops through the script, adjust which frame the action is on using setActionFrame()?
I had the vague impression that properly cued, I could even combine the motions into a hybrid motion, say having a point that was half clap/half wave, or a clap while the hands were also at an extreme positon of the wave.
ATM I can’t experiment but I trust you have played around with using same/different animation layers and blending modes? I just know that the effect which you want should be possible.
You can actually get an action frame you want by using playAction() or the actuator that specifies the starting frame you want.
Yes, I’ve set the two animations to different layers. I’m still only getting one to play. I’m using the playAction command linked to the joystick to set which portion of the action plays.
I tried using the logic blocks and an Always sensor for each Action. The first logic block always got acted upon.
I also tried putting the playAction commands in a single script. Which ever command had the highest layer number got played.
…
Well, writing this gave me an idea, and I tried it. I put a switch into the script that changed the layer numbers depending on the joystick reading, which controls which playAction is executed.
If both actions have the same bones keyframed, Blender will always just play the higher layer action unless you tell the engine how much weight to apply to the layer. Add layer_weight=0.5 to each of your actions and see if that fixes it.
That is good information redbaron5. I got it to play both actions by adding switching code to determine which one to play by choosing the one that has the greater absolute joystick value. I bet I can modify the code to modify the weighting according to the ratio of absolute joystick values. That would give me the control I was looking for. Thank you.