0
using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour 
{
public float speed          = 3.0f;
public float jumpSpeed          = 200.0f;
public bool grounded            = true;
public float time           = 4.0f;     



// Use this for initialization
void Start () 
{

}

// Update is called once per frame
void FixedUpdate () 
{
    Vector3 x = Input.GetAxis("Horizontal")* transform.right * Time.deltaTime *      speed;

    if (time <= 2)
    {
    if(Input.GetButtonDown("Jump"))
        {
                Jump();
        }

    }

    transform.Translate(x);

    //Restrict Rotation upon jumping of player object
    transform.rotation = Quaternion.LookRotation(Vector3.forward);


}
void Jump()
    {
        if (grounded == true)
        {
            rigidbody.AddForce(Vector3.up* jumpSpeed);


            grounded = false;
        }

    }
void OnCollisionEnter (Collision hit)
{
    grounded = true;
    // check message upon collition for functionality working of code.
    Debug.Log ("I am colliding with something");
}

}

地面に戻る前に、どこで、どのタイプのコーディングで 2 回ジャンプできるでしょうか?

その上にスプライト シートを配置したオブジェクトがあり、Unity の物理エンジンに基づいて動きと通常のジャンプを拘束することを取得しました。しかし、私は動きをよりダイナミックにし、地面に静止したときにリセット位置に来る前にジャンプボタンが数ミリ秒間隔で押された場合のように、接地されていない場合と特定の時間枠の間に1回だけジャンプを2回行いたい.

4

1 に答える 1