Hi guys do one of you know a script so that if I have for example collected 200 coins a 2dtexture comes up and leaves after 2 seconds? ty!
I’m rather newbe, but maybe using Playmaker and global variables can be a breeze.
Best off using a particle emitter and set it so it only fires one object and has a life of 2 seconds. Simples.
You could create a GuiTexture. Position it where you want it. Then:
var texture : Texture2D;
var On:boolean;
function Start(){
guiTexture.enabled = false;
}
function Update(){
if(coins==200){
On=true}}
if(On){
GuiGoesOn();}
function GuiGoesOn(){
On=!On;
guiTexture.enabled=true;
yield WaitForSeconds(2);
guiTexture.enabled=false;
}
Now is your coin counting in the same script? Is it a static variable?If yes, call the static with
ScriptName.countVar
If not static, you still can send a message from the script where the counting happens. Somehow like this
in the GuiTexture script
var texture : Texture2D;
function Start(){
guiTexture.enabled = false;
}
function GuiGoesOn(){
guiTexture.enabled=true;
yield WaitForSecond(2);
guiTexture.enabled=false;
}
In the script where coins are counted:
function Update(){
if(coins == 200)
{
On = True;
}
if(On){
gameObject.Find("TheGUItextureObject").SendMessage("GuiGoesOn");
On=!On;
}
}
I edited a little as I realized that it could work but would not be the best.