playMaker

Author Topic: Variable value is not passed from PM to a script when it addresses prefabs.  (Read 1296 times)

Boom7Games

  • Playmaker Newbie
  • *
  • Posts: 9
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

Code: [Select]
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.

Code: [Select]
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?
« Last Edit: September 25, 2014, 02:44:19 AM by Boom7Games »