C'# When Taking Variables From Other Scripts, The Values Do Not Update

Hi, cheers for reading;

-Two classes: Map_Mech & Map_Tile_Generic

-There is one object that contains the script Map_Mech, that object is called pMap_Mech (prefab)

-There are potentially hundreds of clones of the prefab (pTile) that contains the Map_Tile_Generic script. I want the Map_Tile_Generic script to take a value from the single Map_Mech, and use it (accessor functions). I have drag/dropped the Map_Mech prefab into the script area in the pTile prefab, and it finds it (other.getTileScale()) sets to the correct value, as its only assigned once, on create)

Map_Mech:


public Vector3 GetNewVector () { return vNewVector; }

“Map_Tile_Generic”


private GameObject oBase;
	
	public Map_Mech other;
	
	void Awake()
	{		
		oBase = GameObject.CreatePrimitive (PrimitiveType.Cube);
		oBase.transform.position = other.vNewVector;
		oBase.transform.localScale = other.GetTileScale(); 
	}    

Map_Mech changes the value of vNewVector in real time, however, when I use the function, it always returns Vector3(0,0,0); I managed to solve my previous question after posting, so I’m hoping I can do the same XD However, if anyone does know (or has an idea), the info would be fantastic! I’m online every day between 10am-10pm GMT (usually). Ta

If I understood correctly, other is a reference to the prefab Map_Mech - but it should be a reference to the actual instance of Map_Mech that exists in your scene. Instead of assigning other in the Editor, you should find it at runtime, and in Start, not Awake (Awake is called during object creation, and other objects may not exist yet):

    public Map_Mech other;

    void Start()
    {  
       other = GameObject.Find("Map_Mech"); // find Map_Mech instance by name
       oBase = GameObject.CreatePrimitive (PrimitiveType.Cube);
       oBase.transform.position = other.vNewVector;
       oBase.transform.localScale = other.GetTileScale(); 
    }