I have 2 classes : Runner
( the player ) and Manager
( the scene manager ).
Manager
class controls scene resets, object recycling, GUI element display, score calculation, etc. It has a public score
variable:
public int score = 0;
Runner
class controls the characters movement, key inputs, dying criteria, etc.
I now implemented a collision detection of Runner
with other GameObject
, which I plan to have an increase of score. How can I send the “command” to ask Manager
to increase the score?
The collision detection codes in Runner
class is as follow:
void OnCollisionEnter(Collision collison) {
//ContactPoint contact = collison.contacts[0];
if (collison.gameObject.tag.Equals("CollectableTypeA")) {
Destroy(collison.gameObject);
}
}