does this also work ? i went for another approach wanted to know is it just as effective or not ?
public class PrimaryTrigger : MonoBehaviour {
Collider stored;
void OnTriggerEnter(Collider collider)
{
stored = collider;
}
public bool ExpectCollider(Collider c)
{
if (stored == c)
return true;
else
{
return false;
}
}
public class SecondaryTrigger : MonoBehaviour {
PrimaryTrigger pT;
public int points = 1;
private void OnTriggerEnter(Collider collider)
{
pT = GetComponentInParent<PrimaryTrigger>();
if (pT.ExpectCollider(collider))
{
ScoreKeeper sK = FindObjectOfType<ScoreKeeper>();
sK.IncrementScore(points);
}
}
}