|
Hello, 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. Reason: 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. Code: The script on the prefab - cannondestroy.js /*
Code Explanation: 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. My Perception: 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. TRYOUTS: 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
(comments are locked)
|
|
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.
(comments are locked)
|
|
You can use a static variables and functions to access the score script. But I wish to bring down the values to zero every time I load a new scene. So when I load a new scene should I just call a random awake function to revert back the values to 0?
Dec 09 '11 at 12:25 AM
Karsnen
instance = this; Could I please know what the above statement actually does?
Dec 09 '11 at 12:29 AM
Karsnen
(comments are locked)
|
