Add Stop Agent node

This commit is contained in:
unknown 2018-05-15 23:30:47 +02:00
parent bcd78309a5
commit a2bf6a0a90
3 changed files with 53 additions and 2 deletions

View file

@ -0,0 +1,25 @@
package armory.logicnode;
import armory.trait.navigation.Navigation;
import iron.object.Object;
import iron.math.Vec4;
class StopAgentNode extends LogicNode {
public function new(tree:LogicTree) {
super(tree);
}
override function run() {
var object:Object = inputs[1].get();
if (object == null) return;
#if arm_navigation
var agent:armory.trait.NavAgent = object.getTrait(armory.trait.NavAgent);
agent.stop();
#end
super.run();
}
}

View file

@ -21,8 +21,7 @@ class NavAgent extends Trait {
}
public function setPath(path:Array<Vec4>) {
if (rotAnim != null) Tween.stop(rotAnim);
if (locAnim != null) Tween.stop(locAnim);
stopTween();
this.path = path;
index = 1;
@ -31,6 +30,16 @@ class NavAgent extends Trait {
go();
}
function stopTween() {
if (rotAnim != null) Tween.stop(rotAnim);
if (locAnim != null) Tween.stop(locAnim);
}
public function stop() {
stopTween();
path = null;
}
function shortAngle(from:Float, to:Float) {
if (from < 0) from += Math.PI * 2;
if (to < 0) to += Math.PI * 2;

View file

@ -0,0 +1,17 @@
import bpy
from bpy.props import *
from bpy.types import Node, NodeSocket
from arm.logicnode.arm_nodes import *
class StopAgentNode(Node, ArmLogicTreeNode):
'''Stop agent node'''
bl_idname = 'LNStopAgentNode'
bl_label = 'Stop Agent'
bl_icon = 'GAME'
def init(self, context):
self.inputs.new('ArmNodeSocketAction', 'In')
self.inputs.new('ArmNodeSocketObject', 'Object')
self.outputs.new('ArmNodeSocketAction', 'Out')
add_node(StopAgentNode, category='Navmesh')