armory/Sources/armory/logicnode/MapRangeNode.hx
2020-11-17 12:01:15 -03:00

21 lines
503 B
Haxe

package armory.logicnode;
class MapRangeNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function get(from: Int): kha.FastFloat {
var value = inputs[0].get();
var fromMin = inputs[1].get();
var fromMax = inputs[2].get();
var toMin = inputs[3].get();
var toMax = inputs[4].get();
if (value == null || fromMin == null || fromMax == null || toMin == null || toMax == null) return null;
return (value / fromMax - fromMin) * toMax - toMin;
}
}