With the following script i wanted to activate a collider at the left/right side...
...by keeping the A/D key pressed and shortly pressing the E key. The script itself is correct, so it doesn't show an error message, but it doesn't work, the colliders don't get activated. Also the test boolean doean't get activated, could somebody help me with this?
var LeftStop : GameObject;
var RightStop : GameObject;
var Left: boolean;
var Right: boolean;
var Test : boolean;
function Start () {
LeftStop.active = false;
RightStop.active = false;
Left= false;
Right= false;
Test = false;
}
function Update () {
if (Input.GetKeyDown(KeyCode.A)) {
Left= true;
} else if (Input.GetKeyUp(KeyCode.A)){
Left= false;
} else if (Input.GetKeyDown(KeyCode.D)){
Right= true;
} else if (Input.GetKeyUp(KeyCode.D)){
Right= false;
}
}
if (Input.GetKeyDown(KeyCode.E)){
if (Left==true){
Test = true;
LeftStop.active = true;
WaitForSeconds(1.25);
LeftStop.active = false;
} else if (Right==true) {
Test = true;
RightStop.active = true;
WaitForSeconds(1.25);
RightStop.active = false;
}
}
Comment
Your answer
Follow this Question
Related Questions
If script not working as expected - camera switch 1 Answer
NEED HELP!!! How to explode my enemy ship? Need help with C# script 1 Answer
Help with Trigger Colliders.. 0 Answers
Animation doesn't work 1 Answer
Need a Script for Changing Scenes after pressing E to open locked door once a key has been found. 0 Answers