Not reliable SetMaterial node ... maybe the solution


During recent tests, I found that the node SetMaterial is not at all reliable.

Looking a little, I put a patch in the code that can have good results.
In fact, I force the update on all materials.
If you are interested, here is the patch, in a class named SetMaterialSureNode

class SetMaterialSureNode extends LogicNode {
public function new(tree:LogicTree) {

override function run() {
	var object:MeshObject = inputs[1].get();
	var mat:MaterialData = inputs[2].get();
	if (object == null) return;

	var i = 0;
	while (object.materials[i] != null) {
		object.materials[i] = mat;
		i = i+1;

	var objectnew:MeshObject = inputs[1].get();
	var matnew:MaterialData = objectnew.materials[0];

	while (mat != matnew) {
		mat = inputs[2].get();
		object.materials[0] = mat;
		objectnew = inputs[1].get();
		matnew = objectnew.materials[0];;


Currently I use it to make a 3D screen to pass dynamic messages in a scene.

Maybe you also have a proposal to make? :wink:

How to change material parameters dynamically in HAXE script?