Unity:Unity 5的双跳不起作用?

时间:2015-09-11 05:22:47

标签: unity3d

我使用Unity5。

我有一个对象,我把它的比例是(0.2,0.2,0.5),我让我的对象双跳。它有效。

但是当我调整大小比例是(0.5,0.5,0.5)时,它就不能双跳。双跳不起作用。

我真的不明白。帮助我解决这个问题。

我的代码:

using UnityEngine;
using System.Collections;

public class GiantScript : MonoBehaviour
{
    Animator anim;
    public bool grounded, doubleJump, jumping;
    public Rigidbody2D rid;
    public float jump;
    public GameObject  ground;
    public LayerMask mask;
    // Use this for initialization
    void Start ()
    {
        anim = GetComponent<Animator> ();
    }
    // Update is called once per frame
    void Update ()
    {
        grounded = Physics2D.Linecast(transform.position, ground.transform.position, mask);
        if (grounded) {
            jumping = false;
            doubleJump = false;
        }
        if (Input.GetMouseButtonDown (0) && grounded && !doubleJump) {
            jumping = true;
            doubleJump = true;
            rid.velocity = new Vector3 (0, 50 * jump, 0);
        }
        if (Input.GetMouseButtonDown (0) && !grounded && doubleJump) {
            rid.velocity = new Vector3 (0, 60 * jump, 0);
            doubleJump = false;
        }
        anim.SetBool ("GiantRun", grounded);
        anim.SetBool ("GiantJump", jumping);
    }
}

0 个答案:

没有答案