- Home /
I cant make my character jump
Whatever I do, my 3d character does not want to jump (increase y axis). I have a cam that follows the object. It moves up but the object is not moving up.
rb.AddForce(new Vector3(0, 5, 0), ForceMode.Impulse); //I use this when hitting spacebar
Have you tried increasing the jumpHeight
variable? Bump it up and let us know here if it does sth.
It doesnt jump at all, 50 or 100 doesnt work
can you share the rest of your code? Where do you call this?
So when I put this jumping script on a empty cube, the cube flies into the air. However my PlayerObject does not.
![picture][1] [1]: /storage/temp/177378-jumping-script.png
Answer by UnityM0nk3y · Mar 09, 2021 at 05:36 PM
Assuming you are in 2D with a Rigidbody2D:
This code will make you jump by using the "W" key.
Rigidbody2D rb2d;
public float jumpHeight; //adjust me in the editor
void Start()
{
rb2d = gameObject.GetComponent<Rigidbody2D>();
jumpHeight = 20f; //how high you want to jump
}
void FixedUpdate()
{
if (Input.GetKeyDown("w"))
{
rb2d.AddForce(Vector2.up * jumpHeight);
}
}
My situation is for 3D, I have added this to my question :)
Your answer
Follow this Question
Related Questions
I have a problem with my jump script 1 Answer
3D Game-Making a character jump 3 Answers
Jumping only once (2D) 2 Answers
jump and check ground problem! 2 Answers
change multiple jump to single jump 1 Answer