Visual Scripting: Do objects with the same graph share graph variables?

Course “Unity Visual Scripting” - Microbe Mayhem

Why does the course example work, when there is only one distance-variable?

All enemies share this same script graph and there is only one graph variable “distance”, correct ? And this distance-variable is shared by both enemies. So why is one enemy changing its direction and not the other enemy at the same time in the course example ?

I tried the multiply-approach, too, as shown in the picture below (changing only the y-value):

But this did not work properly. Here I have the effect, that both enemies change y-direction at the same time, when one collides.

So what is the difference, between using the “set variable” node and the “get variabe” and “set y” nodes ?

And why does the examples with the “set variable” node work, instead ?

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

I know I’m late to the party, but let me chime in for those who may see this asking the same question.

The reason why the first example works that in a way you’re correct. The same graph applies to all instances of an enemy. However, instances do not share the same value of variables.

Another way to put this is that while the behavior is the same across all enemies, the state of their data is not.

Privacy & Terms