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 ??