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; } }