Unity3d 跳得很短

Unity3d 跳得很短,unity3d,Unity3d,当我的pnj正在运行时(按下右键),y尝试跳过pnj跳跃。但是很少,我怎么能把它溶解呢 当我按下右键时,这不是问题,但我想做一个没有失败的游戏,我想在io运行时跳转,谢谢 void Update () { if (Input.GetKeyDown (KeyCode.Space)) { if (corriendo) { if (enSuelo || !dobleSalto) { Get

当我的pnj正在运行时(按下右键),y尝试跳过pnj跳跃。但是很少,我怎么能把它溶解呢

当我按下右键时,这不是问题,但我想做一个没有失败的游戏,我想在io运行时跳转,谢谢

 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;
            }

        }   
    }
void更新(){
if(Input.GetKeyDown(KeyCode.Space)){
国际单项体育联合会(corriendo){
如果(确保| | | |!多布勒萨托){
GetComponent().velocity=newvector2(GetComponent().velocity.x,0);
GetComponent().AddForce(Vector2.up*fuerzaSalto);
如果(!dobleSalto&&!enSuelo){
多布勒萨托=真;
}
}
corriendo=正确;
}
}
if((enSuelo | | |!dobleSalto)和&Input.GetKeyDown(KeyCode.Space)){
GetComponent().velocity=newvector2(GetComponent().velocity.x,0);
GetComponent().AddForce(Vector2.up*fuerzaSalto);
如果(!dobleSalto&&!enSuelo){
多布勒萨托=真;
}
} 
if(Input.GetKey(KeyCode.RightArrow)&&enSuelo==true){
如果(速度>17){
velocidad=17;
}
GetComponent().velocity=newvector2(GetComponent().velocity.x,0);
GetComponent().AddForce(Vector2.right*velocidad);
velocidad++;
}否则{
如果(velocidad>1){
天竺葵--;
}否则{
velocidad=0;
}
}   
}

尝试在AddForce(Vector2.right*velocidad*jumpFactor)中添加额外变量

在这里,您可以给incremefactor一个值,以便修改跳转的长度