Sending string variable between Udon Behaviors

Uncertain if I’ve gotten the wrong idea of how some of this works, but long story short:

I’m hoping to take a variable stored in the Udon Behavior of an object (a string, specifically), and send its value to another Udon Behavior on a different object.

The end goal is to create an infinitely-expandable Stargate system - where the Address of each gate is automatically added to an array in a central storage location, which can then read from by any gate in the system when dialing (i.e. read address input, if it matches anything in this array then activate dialing, if not shut down gate).

I’m struggling with some parts, but figuring out sending a string variable from one Udon Behavior to another should help finish most of the system.

You’re using Udon Graph, right?

Try SetProgramVariable. It lets you set variables on a different UdonBehaviour. You can then either use SetCustomEvent or OnVariableChange to react to the new value instantly.

Oooooh, was searching around for summat like that but couldn’t find them. Somehow missed “SetProgramVariable” every time I read through the various node pages.

Thanks for pointing those out, they should work perfectly!

1 Like