Question by
dandelo99 · Apr 27, 2016 at 08:15 PM ·
another script
Variable not changing
problem is in bold lines
using UnityEngine; using System.Collections;
public class Triggerenter : MonoBehaviour {
public AudioSource beep;
**public GameObject SeceneTestMap;**
void Update () {
}
void OnTriggerEnter(Collider other)
{
**float hedefCount = SeceneTestMap.GetComponent<SceneTest_Map>().gidilenHedef;**
Debug.Log("Bastın");
beep.Play();
**hedefCount += 1f;**
Destroy(gameObject);
}
}
I have SceneTest_Map script and public float gidilenHefed = 0f; at this script i need to count how many object destroyed so i added hedefCount += 1 but gidilenHedef is not increasing at another script why?
Comment
Best Answer
Answer by Jessespike · Apr 27, 2016 at 08:20 PM
hedefCount is a new float with the same value as gidilenHedef. It's not a reference type.
If you want to change gidilenHedef, then access the SceneTest_Map and change it directly.
SeceneTestMap.GetComponent<SceneTest_Map>().gidilenHedef += 1f;