Added nodes to start animation from a partivular frame index
This commit is contained in:
parent
1534f2565c
commit
1770aeb002
30
Sources/armory/logicnode/PlayActionFromNode.hx
Normal file
30
Sources/armory/logicnode/PlayActionFromNode.hx
Normal 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);
|
||||
}
|
||||
}
|
22
blender/arm/logicnode/animation_play_action_from.py
Normal file
22
blender/arm/logicnode/animation_play_action_from.py
Normal 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')
|
Loading…
Reference in a new issue