-1
私のpnjが(正しいキーが押された状態で)実行され、yがpnjジャンプをジャンプしようとしたとき。しかし、ほとんど、私はどのようにこれをsolucionateすることができますか?ユニティ3dジャンプは非常に短い
これは私が右のボタンを押してみましょう問題はないですが、私が失敗したと私はIOを実行している間、ジャンプしたいずに、thanks¡
void Update() {
if (Input.GetKeyDown (KeyCode.Space)) {
if (corriendo) {
if (enSuelo || !dobleSalto) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, 0);
GetComponent<Rigidbody2D>().AddForce(Vector2.up * fuerzaSalto);
if (!dobleSalto && !enSuelo){
dobleSalto=true;
}
}
corriendo = true;
}
}
if ((enSuelo || !dobleSalto) && Input.GetKeyDown (KeyCode.Space)) {
GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, 0);
GetComponent<Rigidbody2D>().AddForce(Vector2.up * fuerzaSalto);
if (!dobleSalto && !enSuelo){
dobleSalto=true;
}
}
if (Input.GetKey (KeyCode.RightArrow) && enSuelo==true) {
if (velocidad > 17) {
velocidad = 17;
}
GetComponent<Rigidbody2D>().velocity = new Vector2 (GetComponent<Rigidbody2D>().velocity.x, 0);
GetComponent <Rigidbody2D>().AddForce (Vector2.right * velocidad);
velocidad++;
} else {
if (velocidad > 1) {
velocidad--;
} else {
velocidad = 0;
}
}
}