Different result between Event Graph and Construction script

I have a big problem with my script. I get different results when I use a function in my construction script and in my event graph.

To describe my function, it scans all the actors on my level and their materials, and according to the color of the latter, it sets new materials for these actors.

To do this, I use a switch on string on the hexadecimal color of these materials and, depending on the color, set new materials.
However, when I run this function in my construction script, all the outputs of my switch take the same new material: the one to which the largest number is connected (I’ve identified that from 12 or 13 everyone takes the same). However, if I place this function in my event graph, all my switch’s outputs work fine. What’s going on!!! Thank you in advance for any reply.


Sorry for the quality of the photo but the result is that when I use it in my construct script, all of the minor outputs (at the bottom) will take the material of the top ones even if connected to other set material as you can see…

1 Like

You have to know that the construction script runs many times for an asset.

If you’re dragging it around, it can run 10s of times. Even for a single click, it can run 5 times.

Could this be what’s happening?

If you want it to run only once, you can make a ‘run in editor’ event in your event graph, and call it with a button press from construction.

Okay, I have an update: for the bottom set materials that are override « by the majority » if I set some very particular new materials it works… I’m completely lost wtf…

Thx for your answer, I’m not sure to understand: do you mean creating a custom event in my event graph and then call it in the construction script? if it is the case how can I call an event in a construct script?
And my goal is to change all the colors of the components in any projects (these colors are repetitive in all of them) just by adding a folder (that is why I’m working in the construct script of an actor that I just have to place in the level) without starting to play with the green arrow… Would it be possible?

1 Like

Like this

Yes it’s possible.

Thx for your answers it works perfectly with this kind of custom event (I initially thought you were telling me to put the custom event in my construct script :slightly_smiling_face: )

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.