Create and implement Get Nav Agent Data Node

This commit is contained in:
QuantumCoderQC 2021-09-03 20:59:49 +02:00
parent d6692efbdc
commit 8caf859db9
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,25 @@
package armory.logicnode;
import iron.object.Object;
class GetAgentDataNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function get(from: Int): Float {
var object: Object = inputs[0].get();
assert(Error, object != null, "The object to naviagte should not be null");
#if arm_navigation
var agent: armory.trait.NavAgent = object.getTrait(armory.trait.NavAgent);
assert(Error, agent != null, "The object does not have NavAgent Trait");
if(from == 0) return agent.speed;
else return agent.turnDuration;
#else
return null;
#end
}
}

View file

@ -0,0 +1,13 @@
from arm.logicnode.arm_nodes import *
class GetAgentDataNode(ArmLogicTreeNode):
"""Gets the speed and turn duration of the agent"""
bl_idname = 'LNGetAgentDataNode'
bl_label = 'Get Agent Data'
arm_version = 1
def arm_init(self, context):
self.add_input('ArmNodeSocketObject', 'Object')
self.add_output('ArmFloatSocket', 'Speed')
self.add_output('ArmFloatSocket', 'Turn Duration')