- Home /
How set/get var for game creator i c# script?
If I set up a local/global variable in Game Creator, how I able to reference it in a C # script and change him?
I have a player object that I have assigned a local variable to. And in another object, I have a c # script added. How in this c # script to change the local variable assigned to the player object.
I try this examples (https://docs.gamecreator.one/game-creator/systems/game-creator-api/variables-access#set-global-variables) but it not work.
Thanks!
Answer by unity_hosein · Nov 14, 2021 at 03:56 AM
the var only can use in the fanfictions you can't get/set it. but i have a idea how to do it. for set add parameter in front of your fanfiction like that: void test(object o) { var v = o; } & for get var you can use return in the end of your fanfiction like that: object test(object o) { var v = o; return (object)v; }
but i think its better you set your parameter type to object and use it in class not fanfiction