When an object enters a cube, a ‘recoveredOil’ counter is multiplied by a ‘production’ counter. This is the script:
void OnTriggerStay(Collider other)
{
GameObject gameManagementObject = GameObject.Find(“GameManagementObject”);
GameManagement gameManagement = gameManagementObject.GetComponent();
gameManagement.recoveredOil = gameManagement.recoveredOil + (production * Time.deltaTime);
}
}
The ‘recoveredOil’ counter does in fact change but every time the collider exits the cube and re-enters it, the counter is set to 0 again before starting to change.
What am I doing wrong?
UPDATE: I restarted Unity and the script simply worked.