我想更改 int speed 值,但它不起作用。有人能帮我吗?如果您的信息太少,请询问我。这是我的代码:
if (Input.GetKeyDown (KeyCode.W)) {
sprint1 = true;
} else if (Input.GetKeyUp(KeyCode.W)){
sprint1 = false;
}
if (Input.GetKeyDown(KeyCode.LeftShift)){
sprint2 = true;
} else if (Input.GetKeyUp(KeyCode.LeftShift)){
sprint2 = false;
}
if (sprint2 == false && Input.GetKeyUp(KeyCode.W) && Input.GetKeyUp(KeyCode.A) && Input.GetKeyUp(KeyCode.S) && Input.GetKeyUp(KeyCode.D)){
speed = 0;
} if (sprint2==false && (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.D))){
speed = 4;
}if (sprint1 == true && sprint2 == true && Scoped==true) {
speed = 8;
}
我已经解决了我自己的问题。感谢您的所有评论,但我想向您展示我的解决方案:
if (Input.GetKey (KeyCode.W)) {
sprint1 = true;
} else {
sprint1 = false;
}
if (Input.GetKey (KeyCode.LeftShift)) {
sprint2 = true;
} else {
sprint2 = false;
}
if (sprint2 == false && sprint1==false && !(Input.GetKey (KeyCode.A)) && !(Input.GetKey (KeyCode.S)) && !(Input.GetKey (KeyCode.D))){
speed = 0;
} if ((sprint1==true && sprint2==false) || Input.GetKey (KeyCode.A) || Input.GetKey (KeyCode.S) || Input.GetKey (KeyCode.D)){
speed = 4;
}if (sprint1 == true && sprint2 == true && Scoped==true) {
speed = 8;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句