No proper Update and function call between objects ?

TheCollision class detects collision and then calls score class to calculate score

using UnityEngine;
using System.Collections;

public class TheCollision : MonoBehaviour {

	public Pool pool;
	public Poolb poolb;

	private Scores scores;

	void Start()
	{
		scores = GetComponent<Scores>();
	}
	
	void OnTriggerEnter(Collider other)
	{
		if(other.tag == "moving")
		{
			poolb.deActivate(gameObject);
			pool.deActivate(other.gameObject);
//			Debug.Log("Hitting the moving object");
			scores.AddScore();
		}

		if(other.tag == "still")
		{
			poolb.deActivate(gameObject);
//			Debug.Log("Hitting the Still object");
			Application.Quit();
		}
	}

}

Here is the score class

using UnityEngine;
using System.Collections;

public class Scores : MonoBehaviour {
	
	public int totalScore;
	
	public void AddScore()
	{
		Debug.Log("AddScore called");
		totalScore = totalScore + 1;
		Debug.Log(totalScore);
	}

}

Here is the problem
After eliminating 10 enemies my score is still 6 but the function is called for exact 10 times

if function is called 10 times properly then why scores isnt getting updated ??

is it because of framerate ??

The easiest way how to figure out when and where someone is reading / writing to totalScore is to convert it into a property :wink:

public class Scores : MonoBehaviour
{
    private int m_TotalScore;
    public int totalScore
    {
        get { return m_TotalScore;}
        set
        {
            Debug.Log("totalScore is being set to " + value + " was " + m_TotalScore + " before");
            m_TotalScore = value;
        }
    }
    
    public void AddScore()
    {
        Debug.Log("AddScore called");
        totalScore = totalScore + 1;
        Debug.Log("Score after AddScore: " + totalScore);
    }
}

The Debug.Log from the property should have a stacktrace, so you can see from where it’s being called. You could also put a log in the getter if it’s still not clear what’s happening.