Unity3D countdown timer and load level,scean or restart level Tutorial 16
Unity3D countdown timer and load level,scean or restart level Tutorial 16
THIS IS Java scrip: GOOD 4 2D GAMES AND 3D GAMES !
Download all parts HERE
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
Copyright Free Music in this video by:
Song: Virtual Riot - Energy Drink
» Download:
http://bit.ly/RebornDownload
Creative Commons License
http://creativecommons.org/licenses/b...
Artist's Links:
Virtual Riot - Energy Drink
http://www.facebook.com/virtualriotmusic
http://www.soundcloud.com/virtual-riot
---------------------------------------------------------------------------------
THIS IS BACKUP IN TEXT FORM
OFF ALL SCRIPTS OFF TUTORIAL 16
------------------------------------------------
STEP NO.:1
NEW LEVEL LOAD FOLDER
NAME NEW JAVA LIKE THIS :
ONTRIGERENTERLOADLEVEL
COPY AND PAST THIS:
------------------------------------------------
#pragma strict
function OnTriggerEnter(Col : Collider)
{
if(Col.tag == "Player")
{
Application.LoadLevel("MENILEVEL3");
}
}
------------------------------------------------
STEP NO.:2
TIMER FOLDER
NAME NEW JAVA LIKE THIS :
Countdown
COPY AND PAST THIS:
------------------------------------------------
static var gameRunning : boolean = true;
var gameTimeAllowed : float = 20.0;
private var gameMessageLabel = "";
private var gameMessageDisplay : Rect;
private var timedOut : boolean = false;
private var gameTimeRemaining : float = gameTimeAllowed;
function Awake() {
gameMessageDisplay = Rect(10, 10, Screen.width - 20, 40);
}
function OnGUI() {
GUI.color = Color.yellow;
GUI.backgroundColor = Color.black;
var text : String = "";
if (timedOut) {
gameMessageLabel = "Time's up!!";
Application.LoadLevel("MAINMENILEVEL CHOSE");
} else {
text = String.Format( "{0:00}:{1:00}", parseInt( gameTimeRemaining / 60.0 ), parseInt( gameTimeRemaining % 60.0 ) );
gameMessageLabel = "Time left: " + text;
}
GUI.Box(gameMessageDisplay, gameMessageLabel);
}
function Update() {
if (!gameRunning)
return;
// Keep track of time and display a countdown
gameTimeRemaining -= Time.deltaTime;
if (gameTimeRemaining <= 0) {
timedOut = true;
gameRunning = false;
}
}
------------------------------------------------
STEP NO.:3
TIMER FOLDER
NAME NEW JAVA LIKE THIS :
destroj countdown
COPY AND PAST THIS:
------------------------------------------------
#pragma strict
function OnTriggerEnter (other : Collider)
{
if(other.tag == "Player")
{
Destroy(gameObject);
}
}
------------------------------------------------
STEP NO.:4
TRIGER IMAGE
NAME NEW JAVA LIKE THIS :
JPEGAppear
COPY AND PAST THIS:
------------------------------------------------
private var guiShow : boolean = false;
var JPEG : Texture;
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "Player")
{
guiShow = true;
}
}
function OnTriggerExit (Col : Collider)
{
if(Col.tag == "Player")
{
guiShow = false;
}
}
function OnGUI()
{
if(guiShow == true)
{
GUI.DrawTexture(Rect(Screen.width / 4.5, Screen.height / 4, 300, 300), JPEG);
}
}
------------------------------------------------
STEP NO.:5
TRIGER IMAGE
NAME NEW JAVA LIKE THIS :
SOUNDTRIGER
COPY AND PAST THIS:
------------------------------------------------
var soundFile:AudioClip;
function OnTriggerEnter(trigger:Collider) {
if(trigger.collider.tag=="Player") {
audio.clip = soundFile;
audio.Play();
}
}
------------------------------------------------
0 comments:
Post a Comment