Player cannot jump

Hello,

I have a very simple game in mind, where my player has only ability to jump and go down, not pressing just makes the gravity slowly pull you down.

I have attached a ribibody2D along with the following script to player sprite:

    private Rigidbody2D player;
    public float moveSpeed = 10f;
    public float jumpSpeed = 10f;

    void Start () {
        player = gameObject.GetComponent<Rigidbody2D>(); //getting assigned object


    }
	

	void Update () {

        if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.W)) //Going UP
        {
            //   player.transform.position = new Vector3(player.transform.position.x, player.transform.position.y + speed, player.transform.position.z);
           player.AddForce(Vector3.up * jumpSpeed * Time.deltaTime);
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
 
        }

Yet nothing happens when I press space or W. I also tried the commented out position code, it works.

Try checking gravity and mass of the rigidbody, also when dealing with physics, it is better to place physics functions in the FixedUpdate() .

you can also try

player.AddForce (Vector3.up * (jumpSpeed * player.mass * player.gravityScale));