So after struggling with this for several days, I am totally frustrated and really don’t understand what is going on. All i want to do is have a script assign an ID number to a game object each time it spawns. To do this, I pass a value either through a property or through a public function. However, no matter what I do, the value in the target script never changes from 0. Here is the code:
In script 1:
private void AssignObject(GameObject obj)
{
activeObject = obj;
if (activeObject.GetComponent())
{
movementScript = activeObject.GetComponent();
movementScript.ChangeID(activeID);
}
}
Script 2, the target script:
public void ChangeID(int newID)
{
GummiID = newID;
}
I have debugged this thing over and over again. It shows in the first script that movementScript.GummiID = the new value, yet in the actual script it shows it is still 0! Stack trace shows no duplicate scripts. The logic flow is exactly as I want it. I looked up online multiple pages of this and I am certain I have the correct syntax. So why doesn’t the target property update when I call the function?