- Home /
Question by
lasha_an · Aug 21, 2012 at 08:47 AM ·
timewaitforsecondstimescale
how to stop object before GO writes
sorry, i'm asking again about this script, i want to make 1 2 3 GO as most of racing games have, but i cant stop object, untill GO writes, so PLS help. There is script:
static var startGame = false;
var g1 : GUIText;
var g2 : GUIText;
var g3 : GUIText;
var go : GUIText;
var last : GUIText;
function Start ()
{
g1.text = "3";
yield WaitForSeconds (1.0);
g1.text = "";
Time.timeScale = 0.0;
g2.text = "2";
yield WaitForSeconds (1.0);
g2.text = "";
Time.timeScale = 0.0;
g3.text = "1";
yield WaitForSeconds (1.0);
g3.text = "";
Time.timeScale = 0.0;
go.text = "Go";
yield WaitForSeconds (1.0);
go.text = "";
Time.timeScale = 1.0;
startGame = true;
}
Comment
simply use "Invoke". it is the basic command used in program$$anonymous$$g video games.
To cancel an invoke ..you use CancelInvoke :)
That's the second most common command in program$$anonymous$$g video games.
Best Answer
Answer by lasha_an · Aug 21, 2012 at 09:20 AM
static var startGame = false;
var g1 : GUIText;
var g2 : GUIText;
var g3 : GUIText;
var go : GUIText;
var last : GUIText;
function Start ()
{
g1.text = "3";
saveVelocity = rigidbody.velocity;
saveAngularVelocity = rigidbody.angularVelocity;
rigidbody.isKinematic = true;
yield WaitForSeconds (1.0);
g1.text = "";
g2.text = "2";
saveVelocity = rigidbody.velocity;
saveAngularVelocity = rigidbody.angularVelocity;
rigidbody.isKinematic = true;
yield WaitForSeconds (1.0);
g2.text = "";
g3.text = "1";
saveVelocity = rigidbody.velocity;
saveAngularVelocity = rigidbody.angularVelocity;
rigidbody.isKinematic = true;
yield WaitForSeconds (1.0);
g3.text = "";
go.text = "Go";
rigidbody.isKinematic = false;
rigidbody.velocity = saveVelocity;
rigidbody.angularVelocity = saveAngularVelocity;
rigidbody.WakeUp();
yield WaitForSeconds (1.0);
go.text = "";
startGame = true;
}
this worked, thx everyone :)