package armory.logicnode; import iron.object.Object; import iron.math.Vec3; import armory.trait.physics.RigidBody; class LookAtNode extends LogicNode { public function new(tree:LogicTree) { super(tree); } override function run() { var targeter:Object = inputs[1].get(); var target:Object = inputs[2].get(); var threeDeeTrack:Bool = inputs[3].get(); var targeterRot:Vec3; var targetLoc:Vec3; if (targeter == null || target == null) return; targeterRot = new Vec3(targeter.transform.rot.x, targeter.transform.rot.y, targeter.transform.rot.z); targetLoc = new Vec3(target.transform.loc.x, target.transform.loc.y, target.transform.loc.z); var newZLook = targeterRot.z + (targeterRot.z - (targetLoc.y / targetLoc.x)); if ( threeDeeTrack == true ) { targeter.transform .setRotation(targeterRot.x, targetLoc.y, newZLook); } else { targeter.transform .setRotation(targeterRot.x, targeterRot.y, newZLook); } #if arm_physics var rigidBody = targeter.getTrait(RigidBody); if (rigidBody != null) rigidBody.syncTransform(); #end super.run(); } }