Question by
nirto_pineapplez · Apr 14, 2016 at 12:02 PM ·
javascriptgameobjectenablekeypressed
how to enable a java script inside a gameobject on press of the space key?
hey, I'm trying to make a racing game and I would like it to start still until the space key is pressed
.thanks NITRO.P (I'm using the latest unity 5.3.4 )
screenshpt.png
(75.9 kB)
Comment
Best Answer
Answer by Gamedragon · Apr 15, 2016 at 02:43 AM
If you add this script:
var script_to_enable : Behaviour;
function Start () {
script_to_enable.enabled = false;
}
function Update () {
if(Input.GetKeyDown(KeyCode.Space)){
script_to_enable.enabled = true;
}
}
To your Game Object and then drag the nameOfScriptToControl script to the script_to_enable variable in the editor it should work.
I hope this helps!
thank you so mutch you have really helped you're the best thanks again. :)