Hi. Im making a game in which the player moves around w/ a flashlight. Over time the flashlight dies, unless the player collides with ‘batteries’. The battery lvl of the light is set in batt_lvl int in my flashlight script, but i need to access the var and set it back, upon colliding with battery FROM a different script. I have collision working, but im having trouble accessing/changing the var in the move_player script. Please help, thanks.
FLASHLIGHT SCRIPT
public var batt_lvl : int;
function Update () {
batt_lvl -= Time.deltaTime;
}
MOVE SCRIPT
public var lightScript : flashlight; //trying to access the script??
function OnCollisionEnter2D(batt: Collision2D)
{
if(batt.collider.name == "battery")
{
Destroy(batt.gameObject);
lightScript.batt_lvl = 7000; //**problem (wont change
}