I know for sure that this question has been answered before but because in each answer the solution presented was adjusted to someone’s classes, variables, etc it was difficult for me , who just begun to work in unity, to understand it.
My problem through a very general example :
I create a cube in the Hierarchy using the create button. Then I drag the cube from the hierarchy to the project tab (so im creating its prefab i guess). Then i add the following js script, named Cube_script, to both “hierarchy cube” and “prefab cube”:
#pragma strict
public var variable = 10000000;
function Start () {
}
function Update () {
variable = variable - 1;
}
Then i hit play and i observe from the inspector that that the variable from the “hierarchy cube” is decreasing but the variable from the “prefab cube” is staying the same. All i want to do is to force the variable of the “prefab cube” to “follow” the variable of the “hierarchy cube”.