jumping at a degrees angle

I have this simple script which makes the character but I don’t know how to make a the character move at an angle e.g. 45 degrees. I have already tried it but it is not working. I have tried changing the values but it doesn’t work the way I want. It is meant to move upwards at a 45 degree angle but it doesn’t.

rigidbody2D.AddForce (new Vector2 (0f, jumpForce));

The code above is the original but I changed it to this and still doesn’t work.

rigidbody2D.AddForce (new Vector2 (5f, jumpForce));

It still doesn’t work so how do I do it. I’m working in C#. Thanks in advance for any replies. Oh and I have already tried searching but nothing came up on this.

If you want your character to always jump at a 45 degree angle (from flat ground, at least), regardless of their current speed, you should be able to do it with something like:

rigidbody2D.velocity += (Vector2.up * rigidbody2D.velocity.x);

Modifying the velocity directly rather than using AddForce, in this case, will ensure that mass is not a factor in the force added.