I have a car which hits a game object to collect points and then be killed. I have a script which has a simple method
void getRewards (int theReward) {
rewardGood += theReward;
}
and I am passing from PM using Send Message an int variable with value 100 to theReward variable of the method.
I want the variable to be read by the method and be passed to a GUI object so that it increases my score.
void OnGUI ()
.
.
.
score = 10 + (hitComp.scr_GoodBehaviour + trafficLightComp.reward + hitComp.bonus - (Mathf.RoundToInt(minutes)*10))-hitComp.scr_HitSomething+rewardGood;
note the last part of the code line rewardGood.
this is working just fine on the original game object i have on the scene but when i turn this to a prefab and create multiple such objects on the scene, the program only registers the score the first time on the object which is not a prefab and ignores the prefabs eventhough their other operations ( such as deleting each object when is "picked up" ) work.
Any help?