I need a help with the score system in my game. Any help will be greatly appreciated.

I have a simple 2d game. This game has two launcher gameobject that launches objects.I have a platform in the middle and one launcher each side.One launches objects after 1 second and other launches after 5 seconds… I want to add 1 score everytime an object is thrown from the launcher. The script is simple. I added the following script after the object instantiation code.[Note: the script is added in the inspector of both launcher.]


So the problem is, the score is updated 1 after one launcher launches object but not added when other launcher launches object. To clarify it simply, the score is updated alternately when object is launched. Need help. Thank you.

You need to make your score static between instances of your class.

public static int score = 0;

Static means the value is shared between instances of your class. As it is now both of your launchers have their own score that they add points to.