Play Action Node


#1

I have been able to to use most of the nodes. The one that I cannot get to work is the play actions node.

I simply added a keyboard input. Is there anything special that needs to be done to play an animation? I added two actions and saved as a fake user for each. This has not worked on any Armory3D version for a couple of months. I even opened someones file up to look at what they did. They had a simple setup that was just like mine. Theirs works though.


#2

I have found many Issues with the animations. I have had your same experience. The examples seem to work and whatever I try doesn’t work right. The only thing I can think of is how you set it up being different. Any information on this topic would be awesome.


#3

@dj_graphics and @Monte_Drebenstedt
Same experience as you too.
As you, I made tests with simple things using the Play Action until complicated things with armatures and bones … behaviors are too much undeterminist to be useable … or we need the cookbook.

Maybe @lubos could help us to know the good way to set an exemple with a simple scene with several cubes (with bones or not) that are animated through keyboard different inputs and use the Play Action, Pause and Resume.


#4

…if I remember correctly, you have to create an NLA strip from an action. Only then, the animation sequence will be exported and is available in Armory.


#5

Even when doing so - the action will play automatically and repeat over and over. Adding a pause action doesn’t seem to work right. I have also tried adding a idle (an animation that does nothing) as the first strip and it doesn’t always work correctly. I am able to get the action to Armory constantly but not get it to function the way I think it should.


#6

I remember having problems, too, with the “pause action” node. However, try muting the NLA strip (click on the little speaker icon) and the animation should not play automatically.


#7

For my part, the problem came from an obsolete version of software Armory with blender 2.8
With last today version image
it’s perfect and new nodes are available for animation too ! thks @lubos


#8

Im able to play actions via nodes.
My problem is, that I cant set start frame of some actions.
Every played action is always looping. And if is interrupted, it remebers the last played frame.
Some of my animation needs to play from start frame.


#9

@antom
Normaly if you set thing like that image for example,

here you need a Play Action to start something … otherwise nothing happens and thus no looping!

(using the toggle channel mutting image)

You can use too an action with only one keyframe as the “Rest” action and put it in the top of the list inside your animation to be sure to start somewhere well determine (ask the Play Action node with it at end of animation to return back at a Rest state for example)

You can use the Pause Action node too.
Example

If not ok, try updating like me before continuing :wink:


#10

Try to imagine…Idle fighting animation is playing. If I press some key, my character is doing some “special move like punch or kick”. Animation for the first time starts from frame 0 and ends on frame 10. But is interrupted with enemy attack in frame 5. After being hit animation and returning to state where Im able to attack agian, my animation “special move like punch or kick” starts at frame 5. Not 0.


#11

Try updating to the newest version of armory and checking out the new animation nodes that have been added. I think they address your concerns directly.


#12

I am up to date. Nodes are the same. What I mean is I cant control action playback type.
This is logic brick from old BGE.


You can choose “start frame”, end frame, playback type…and many more
Play - Play F-Curve once from start frame to end.(this is what I need)
Loop - Play F-Curve continuously from start to end.
Continue - Restore last frame when switching on/off, (this is what Armory is always doing, when switching animations)

It would be great if Play Action node have some playback options.


#13

@antom
Sure, it would be helpful to set precisely a frame.

remark : If you try to do it with your own logic node in Haxe (like a simple Frame Action image ), it seems that actually, even if we have access to the frameIndex or iron.system.Time.time(), we don’t have acess to the animation.tracks or something equivalent to make it with the actual Armory code.


#14

After many tests,maybe those 3 following infos could help some of you to get good results in animation with Logic Nodes & Actions:

1/ for each Action you have in the Action Editor, if you use bones in Armature, be sure that for each keyframe in Pose Mode, you did the “I” and “Whole Character” , otherwise strange behaviors can appear …

2/ using this thereafter “Play Action with Params” node can be helpful to control animations

image

code for the blender.py

class PlayActionParamNode(Node, ArmLogicTreeNode):
‘’‘Play action Param node’’’
bl_idname = ‘LNPlayActionParamNode’
bl_label = ‘Play Action with Params’
bl_icon = ‘GAME’

def init(self, context):
    self.inputs.new('ArmNodeSocketAction', 'In')
    self.inputs.new('ArmNodeSocketObject', 'Object')
    self.inputs.new('ArmNodeSocketAnimAction', 'Action')
    self.inputs.new('NodeSocketFloat', 'Blend')
    self.inputs.new('NodeSocketFloat', 'Speed')
    self.inputs.new('NodeSocketBool', 'Loop')

    self.inputs[-1].default_value = 0.2

    self.outputs.new('ArmNodeSocketAction', 'Out')
    self.outputs.new('ArmNodeSocketAction', 'Done')

then the code for the new Node

package armory.logicnode;

import iron.object.Object;
import iron.object.BoneAnimation;

class PlayActionParamNode extends LogicNode {

public function new(tree:LogicTree) {
super(tree);
}

override function run() {
var object:Object = inputs[1].get();
var action:String = inputs[2].get();

  var blendTime:Float = inputs[3].get();
  if (blendTime == null) blendTime = 0.2;

  var speed:Float = inputs[4].get();
  var loop:Bool = inputs[5].get();
  if (loop == null) loop = false;
  
  if (object == null) return;
  var animation = object.animation;

  if (animation == null) animation = object.getParentArmature(object.name);

  animation.speed = speed;
  animation.loop = false;

  var loop = false;
  // .... cf. anim.play(s, null, blend, speed);
  //trace(' --- action=${action}   .');
  //trace(' --- blendTime=${blendTime}   .');
  //trace(' --- speed=${speed}   .');
  //trace(' --- loop=${loop}   .');

  animation.play(action, function() {
  	runOutputs(1);
  }, blendTime, speed, loop);

  runOutputs(0);

}
}

3/ if not already used, considering the use of the node Animation State is helpful to follow what’s going wrong

exemple of usage
image


#15

Thank you very much for your work…Im testing your node right now. If I play my anim thru it, it stops on last frame.(Even if loop is selected, but I think you allready know that)

What i recently found is, if I play my anim thru stock “play action” node, and no blending is set(0.000), It plays from start. Even if its iterrupted and played again.


#16

This is my node setup.
node%20setup
If I left click, next anim is played and paused. Console says, that the very first frame of next animation is the last frame of previous.

If not paused, the second frame is 0, if blending is 0.


#17

Houps , yes the line with “var loop = false” is to delete.


#18

Another some quick 2 tips :slight_smile:
if you encounter like me problems with strange actions repetitions using the Play Action (with Params) Logic Node … try/verify this (maybe for last remark of @antom too )

1/ Stashing :
Has you will use Action Play nodes or Haxe Traits to activate your Actions, be sure that you hidde thoses Actions … thus do Stash :wink: .
Thus verify that you have used the Stash icone after creating your Action (using the snowflake icon image )

thus this Stashes the active action on to the NLA stack => added as a non-contributing stack and you see it like that image

2/ Cleaning :wink: :


click on this “2” or more number
This will create a Balle-Rest.001 for example, and so you get a new action cleaned.
Now use this one in place of the preceeding one (so here Balle-Rest.001 replaces Balle-Rest).
image
I don’t know why, but it can save time to try this :slight_smile:


#19
  • Armory 0.5a downloaded and updated

  • My Scene is New blend, with simple armature with 2 bones,
    with 2 cubes(as one joined mesh) parented with automatic weights.

  • Created 2 simple animations for armature. Each 60 frames long.
    Mouse left click plays AnimOne, right click plays AnimTWO. Animation speed is set to 0.2 for better debug.

Switching those 2 animations with

  • “play action” or
  • “play action with parameters”
  • Tried anims as “sigle user copy”
  • ("Stash"ed actions are not accessible from play action nodes)

Debug shows the same bug…

SETUP1

SETUP2

SETUP 3
-If blending is 0, and action is immediately paused with “pause action” node, console shows that
next animation start frame, is the last frame, from previos animation
(I dont know why, because SETUP2 shows something else)

setup3

I think that Lubos is aware of this because…

fixactionstart

twitter


#20

So you can’t see an Action slashed into the list of available Actions into the Play Action Node ?