I am trying call another function which is attached to a gameobject( On the scene). But I want to call that function from a Prefab. This prefab is instantiated during run time.
I am checking for collision on one script (on Prefab). If there is a collision on one then I want to call another function (on a gameobject) which would update the SCORE for me. In this way I could display variable carrying the score through OnGUI function.
The script on the prefab - cannondestroy.js
As per the code - it checks for collision. It checks for collision both on the floor and enemy. If the enemy is a hit I wish to update the scoreline else if the floor is the hit I wish to increase the miss score. The other script that is attached onto to gameobject on every scene would be la_point.js.
I am using a lot of scenes. With the prefab fixed, I could alter the variables on the gameobect which is one the scene view for every scene. The script is going to the same but scores will start from zero always when a new level is loaded.
I tried to attach the script which has the gameobject onto the script on the prefab (again on project folder). But it did not work. I see that I can't do that too.
I humbly REQUEST for help as I am trying solve this which is every important information that has to be given to the user.
THANK YOU very much in advance
asked Dec 09 '11 at 12:03 AM
you could do:
hope that helps. I don't get static stuff myself so I don't bother with that. plus, unless you use DontDestroyOnLoad, you should be fine with it resetting.
I'm not completely sure that you can modify the variable but you probably can.
You can use a static variables and functions to access the score script.
answered Dec 09 '11 at 12:19 AM