0

I am new to game programming. I am working on a game in which user points can be updated by multiple actions (like completing 10 meters, coins collections etc). Can anybody help me what approach can I follow here to update points as there are multiple actions which can update same variable at the same time

Ashwani K
  • 7,880
  • 19
  • 63
  • 102

1 Answers1

1

Usually the overall points and the kind go in a static variable while the level related points are instantiated in the game manager.

The best approach is to make your game manager as a singletone class (see Unity singleton manager classes) and put there a static AddPoints(int) method. That will solve nicely your problem without any concurrence problem because Unity processes the classes and methods sequentially, so it's impossible to have concurrency issues in a class inheriting from MonoBehaviour.

Community
  • 1
  • 1