# I found the observer effect(quantum mechanics)

So here is the part of the code where I make changes and it magically affects the logic.

I made a predefined dispersion pattern for shooting. I have two patterns triangle and quad.
And here is how the same logic works totally differently by making a log or without. There are no other changes, just this log. I don’t have an idea why the log so heavily affects the logic.

The logic works as intended for the triangle if the log is off, and for the quad if the log is on.
Triangle pattern - log on (1)

Triangle pattern - log off (2)

Quad pattern - log on (1)

Quad pattern - log off (2)

Try to store the rotation and the location value you get from the node on the left into a transform variable before calling the print string. And use the content of this stored variable to feed the print string as well as the Spawn Actor location/rotation.

This proably will make your problem go away, because in your code, Print string and Spawn Actor both trigger the execution of some part in your blueprint on the left (not visible in your screenshot), which most likely delivers different results when run again for the Spawn Actor.

See also my post here on blueprint strange effects that may happen due to the fact, that these are executed backwards.

1 Like

Thanks for the attempt - it doesn’t fix the issue but this changes behavior
Here the difference
For this case

And for this

Try to store the complete output from your dispersion pattern node into a transform single variable to see, if it helps:

And use this to get the values for print and spawn actor input.

1 Like

I don’t understand why but now this works for all cases - triangle/quad and with/without log
Thank you very much

All patterns are ok now

I don’t know why precisely but we can explain this by understanding that if a node comes after another node, so node then arrow then node, it doesn’t mean that this will be calculated in game one after another. There are maybe thousands other hidden steps inserted by the engine between those nodes.

So because you are calculating a velocity, if you have a third node put in between the two single nodes I was mentioned, now there is even more stuff calculated between these nodes and that takes time and results may be different.

just to cut to the chase, found this the hard way, unreal engine is not linear in execution, especially when using blueprints, some stuff is calculated at different times and is not guaranteed you get the results when you want them and in the order you want them.

So it requires knowledge of the precise order of steps unreal does, when it will insert your blueprints and more precisely where your custom blueprint will end up in this execution order

This is a fascinating and deep rabbit hole.

anyway, physics are calculated at some point, print to log at other points. maybe this messes your code up

1 Like

It looks like you’re experiencing some interesting behavior in your code.

seems to me the problem was the return node, when he added the print string he returned which ended the function so the sequence doesnt complete.

also DoOce doesnt work inside functions either

1 Like

The observer effect in quantum mechanics is a fascinating concept, and it’s intriguing to see how it might apply in a programming context. Your approach of using a log to debug the different patterns is smart, but it’s puzzling why the presence of the log would affect the logic so significantly.
Overall, keep experimenting and debugging, and hopefully, you’ll uncover the reason behind this curious behavior. Check out quantumai.co for more insights into quantum mechanics and its applications in programming!

The reason was connected with pure function. Later I caught a lot of issues because of that, now I use it very cautiously