[SOLVED] Position callback not always fired by NodeTrigger


Recommended Posts


I'm trying to update a node depending on the position of two other nodes in UnigineScript.

First I load the node structure from a .node (reference file) and get its root using the getReference() function.

Here is how the structure looks like :

  • root
    • pole1
    • pole2
    • top

I add a NodeTrigger to pole1 and pole2 and set their position callback using the setPositionCallback() function. The same function is used as a callback for both NodeTriggers.

After this new structure being initialized, the callback seems to be correctly set sometimes only for pole1, sometimes for pole2, sometimes for both and sometimes for none of them.

Any ideas on what can be causing this undefined behavior?

Thanks in advance

Link to post

I was creating a minimal test scene and I accidentally solved the problem haha.

At some point, I was using getPosition instead of getWorldPosition.

But, I have another question : how can I edit the texCoordinates0 for a static mesh in Unigine script?

For now, here is my code which compiles but crashes the editor upon execution :

Mesh topbar = node_cast(gantry.findNode("top"));

Vec3 p1 = trigger1.getWorldPosition();
Vec3 p2 = trigger2.getWorldPosition();
float x = p1.x - p2.x;
float y = p1.y - p2.y;
float z = p1.z - p2.z;
Vec3 dir = Vec3(x,y,z);
float l = length(dir);
Node topbar_node = node_cast(topbar);
Vec3 s = topbar_node.getScale();
s.z = l;
int indices = topbar.getNumTIndices(0);
for(int i = 0; i < indices; i++)
	Vec2 temp = topbar.getTexCoord0(i, 0);
	topbar.setTexCoord0(i, Vec2(l,temp.y), 0);


Edited by karim.salama
Link to post

Nevermind, it just worked for a couple of times in a row.

Here is a minimal test scene I attached to the post.

You have to change the Unigine sdk path in launch.bat.

To test the plugin, you click on the "Create Gantry" button in the wiring tool window and choose "gantry_template.node"



Edited by karim.salama
Link to post

Hi @silent,

I managed to achieve the desired effect by keeping track of the node in the nodeInit method, and applying the necessary updates in the plugin's update function.

I think this issue is solved.

Thank you.

Link to post
  • silent changed the title to [SOLVED] Position callback not always fired by NodeTrigger