- Home /
gameObject does not function properly when used as an asset
I am making a game with an in game coin system (not literally but it functions the same way) and when I save the specific object as an asset to make further use easier, it stops working. It does not stop working entirely but it stops using the code after a certain line. This problem does not occur with the default object and is only with asset versions of it. To be more specific, it does not perform any of the script after the first line under += coinValue. I can duplicate the object to use it again in proper form but that will obviously become a bit tedious and annoying when I have to place them far apart.
Just to simplify: I'm making a score coin system and it works fine but when the object is turned into an asset it stops working after the add score line in the script.
#pragma strict
var coinValue = 1;
var GuiText : GameObject;
GuiText.SetActive(false);
function OnTriggerEnter (collision : Collider)
{
GameMaster.currentScore += coinValue;
GuiText.SetActive(true);
audio.Play();
yield WaitForSeconds(0.5);
GuiText.SetActive(false);
Destroy(gameObject);
}
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Playing audio when a button is clicked? 1 Answer
Changing 3d text through script 1 Answer
Playing multiple sounds with multiple subtitles 1 Answer
On collisionenter name == redblock 0 Answers