From 357aef589184caf18cdc542681c15d439593dea5 Mon Sep 17 00:00:00 2001 From: ARIEL GIMENEZ Date: Wed, 14 Feb 2024 08:27:14 -0300 Subject: [PATCH] GetLocationNode Static methods in the nodes so that the nodes API can be used within HAXE --- Sources/armory/logicnode/GetLocationNode.hx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Sources/armory/logicnode/GetLocationNode.hx b/Sources/armory/logicnode/GetLocationNode.hx index 006844736a..58a0c3a0d2 100644 --- a/Sources/armory/logicnode/GetLocationNode.hx +++ b/Sources/armory/logicnode/GetLocationNode.hx @@ -12,20 +12,26 @@ class GetLocationNode extends LogicNode { var object: Object = inputs[0].get(); var relative: Bool = inputs[1].get(); - if (object == null) return null; + return GetObjectLocation( object, relative ); + } + //STATIC CLASS + public static function GetObjectLocation( object : Object, relative : Bool ) { + + if (object == null) return null; + var loc = object.transform.world.getLoc(); - + if (relative && object.parent != null) { loc.sub(object.parent.transform.world.getLoc()); // Add parent location influence - + // Convert loc to parent local space - var dotX = loc.dot(object.parent.transform.right()); - var dotY = loc.dot(object.parent.transform.look()); - var dotZ = loc.dot(object.parent.transform.up()); + var dotX:Float = loc.dot(object.parent.transform.right()); + var dotY:Float = loc.dot(object.parent.transform.look()); + var dotZ:Float = loc.dot(object.parent.transform.up()); loc.set(dotX, dotY, dotZ); } - + return loc; } }