Create and implement Get Nav Agent Data Node
This commit is contained in:
parent
d6692efbdc
commit
8caf859db9
25
Sources/armory/logicnode/GetAgentDataNode.hx
Normal file
25
Sources/armory/logicnode/GetAgentDataNode.hx
Normal 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
|
||||
}
|
||||
}
|
13
blender/arm/logicnode/navmesh/LN_get_agent_data.py
Normal file
13
blender/arm/logicnode/navmesh/LN_get_agent_data.py
Normal 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')
|
Loading…
Reference in a new issue