Set variable and then keep it that way

Hello, what I’m trying to do is set a variable from another variable and then when the variable the other variable is set to changes the first variable doesn’t. That sounds to complicated here’s a simpler version.

Let’s say i have 2 int variables
the first one and the second one is:

var int1 : int;
var int2 : int;

now i have a string variable.

var stringname : string;

but stringname is named after the 2 int variables
and is formatted like this: “stringname[int1 value, int2 value]
but after stringname is named, i then want to keep it named that way even after int1 & int2 values are changed. I know it sounds complicate, sorry :confused: i just can’t figure this out for the life of me. Thanks in advance. ;D

If I understand your question:

Raw data types (i.e non-objects) work as you intend.

var x : int;
var y : int;

var z : string;

x = 1;
y = 2;
z = "stuff" + x + y; // stuff12

x = 100; //x changes but z remains stuff12

However, objects behave differently since you’re really dealing with a pointer to the object and thus you just assign the pointer (i.e you know have 2 pointers to the same object)

var x : GameObject;
var y : GameObject;

x = GameObject.Find(...);
z = x; // both z and x point to the same object
       // and thus any changes to x apply to z and vice versa

If you didn’t want this functionality, you would need to make a copy of the object (creating a new instance). This way, you end up with x pointing to the original object and z points to its own, copied object.