I am making some kind of casual sport game with some rhythm-tap contents.
I tried to make a system of touching to decide what score you get for that trial.
A target pad comes down from top, and there is a “node”. If you touch right in time(when the node is in the target area), it will gives you certain amount of score.
the dark green-white area is target, and the white line under red person is node.
I have named dark-green area “pass”, light green area “good”, and white area “perfect”.
And I have created a code
using UnityEngine;
using System.Collections;
public class NodeCtrl : MonoBehaviour {
public GameMgr gameMgr;
public int score = 0;
void Awake(){
gameMgr = GameObject.Find ("GameMgr").GetComponent <GameMgr>();
}
void OnTriggerEnter(Collider coll){
if (coll.CompareTag ("PERFECT")) {
Debug.Log("perfect");
score += 1;
}
if (coll.CompareTag ("GOOD")) {
Debug.Log("good");
score += 1;
}
if (coll.CompareTag ("PASS")) {
Debug.Log("pass");
score += 1;
}
coll.enabled = false;
}
public void SendBackScore (){
Debug.Log (score);
//GameObject.Find ("GameMgr").GetComponent<GameMgr>().Call(score);
gameMgr.Call (score);
score = 0;
}
}
However the console log occasionally says that I have got “miss”(which is 0 of score) when appropriately matching the node into target area. It happens about once in 5~15 trials randomly. By checking with Debug.Log(), it seems like to be that the OnTriggerEnter() part of my code does not work properly.
What can I do for solving this?
