Home Game Development How to increment a counter shared between a number of objects?

How to increment a counter shared between a number of objects?

0
How to increment a counter shared between a number of objects?

[ad_1]

I’ve 4 objects that begin off purple, all cases of the identical prefab.

The participant strikes as much as these objects and presses house to alter them to inexperienced.

Each object has an integer variable that will increase by one when the thing turns inexperienced, and that worth goes down once more as soon as it adjustments again to purple.

The participant wants to alter all 4 objects to inexperienced worth earlier than the extent can advance

But every time an object adjustments to inexperienced, it simply increments the thing’s variable from 0 to 1, even when the participant had already incremented the variable on different objects.

How do I get this integer to go up consecutively till it equals 4, and never simply going as much as one for each separate occasion?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here