Added nodes to start animation from a partivular frame index

This commit is contained in:
QuantumCoderQC 2020-03-14 23:30:09 +01:00
parent 1534f2565c
commit 1770aeb002
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,30 @@
package armory.logicnode;
import iron.object.Object;
import iron.Scene;
class PlayActionFromNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function run(from: Int) {
var object: Object = inputs[1].get();
var action: String = inputs[2].get();
var startFrame:Int = inputs[3].get();
var blendTime: Float = inputs[4].get();
if (object == null) return;
var animation = object.animation;
if (animation == null) animation = object.getParentArmature(object.name);
animation.play(action, function() {
runOutput(1);
},blendTime);
animation.update(startFrame*Scene.active.raw.frame_time);
runOutput(0);
}
}

View file

@ -0,0 +1,22 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class PlayActionFromNode(Node, ArmLogicTreeNode):
'''Play action from node'''
bl_idname = 'LNPlayActionFromNode'
bl_label = 'Play Action From'
bl_icon = 'QUESTION'
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('ArmNodeSocketObject', 'Object')
self.inputs.new('ArmNodeSocketAnimAction', 'Action')
self.inputs.new('NodeSocketInt', 'Start Frame')
self.inputs.new('NodeSocketFloat', 'Blend')
self.inputs[-1].default_value = 0.2
self.outputs.new('ArmNodeSocketAction', 'Out')
self.outputs.new('ArmNodeSocketAction', 'Done')
add_node(PlayActionFromNode, category='Animation')