为什么跳跃功能不起作用?我错过了什么? unity3d

时间:2016-10-31 16:04:21

标签: c# unity3d

正如标题中所说,跳跃功能不起作用(角色根本不会跳跃),但其余功能完全正常。什么错了/我错过了什么?

    using UnityEngine;
using System.Collections;

public class Controller : MonoBehaviour {
    private Rigidbody2D rb;
    public float speed = 10.0f;
    Vector2 jump;
    void Start () {
        rb = this.gameObject.GetComponent<Rigidbody2D> ();
        jump  = new Vector2 (9f, 20f);
        Debug.Log (jump.ToString());  //works, outputs 9,20
    }

    void Update () {
        Vector2 movement = new Vector2 ((Input.GetAxis ("Horizontal")* speed), 0);
        rb.AddForce(movement);  //works fine...
        if (Input.GetButtonDown ("Jump")) {
            Debug.Log ("Gets called1"); //works
            Jump ();
        }
    }
    void Jump (){
        rb.AddForce (jump);
        Debug.Log("Gets called2"); //works

    }

}
你能帮帮我吗? Rigidbody settings picture

0 个答案:

没有答案