Unity 3d player jump does't work, rb.addforce doesn't work

unity jump without rigidbody
unity jump script 3d
unity smooth jump
unity character controller jump
unity jump 2d
unity hold to jump higher
unity floaty jump
how to make an object jump in unity

I have a very basic infinite runner and I want to make my player jump. I have attached rigidbody to my player, have instantiated it. here is some part of my code

 void FixedUpdate()
{
    if (OnGround)
    {
        if (Input.GetKeyDown(KeyCode.Space))
        { 
            rBody.AddForce(new Vector3(0, 10, 0), ForceMode.Impulse);
            Debug.Log("jump");
            OnGround = false;
        }
    } 
}     

void onCollisionEnter(Collision other)
{
    Debug.Log("collision");
    if (other.gameObject.CompareTag("ground"))
    {
        OnGround = true;
    }
}

I have tried to put this part in Update(), no result. The interesting part is that Debug.Log("jump") shows on the console, but the player doesn't want to jump. Method void CollisonOther() is never called. I have also tried to change velocity and use transform.translate, no result

jump. How can I make it jump?

There are a couple of things that could be the issue. Make sure the isKinematic box is unchecked. It's also possible that the character is jumping but you cannot see it if your sprites were imported too big (ie: it's jumping a very very small amount relative to the size). You could try printing some more debug statements of the character's position to see if it is actually changing or not.

How do I make my player jump?, Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop,  Looks perfect for every jump up and then falling back down. HOWEVER: when the player JUST falls (like off a cliff oder something) without a jump it looks like he has the mass of a leaf. Sailing to the ground extremley slowly. Not accelerating at all. Just falling as in slow motion.

OnCollisionEnter should have a capital O instead of lower case. As written, onCollisionEnter will never be entered.

That's the only code problem that could be wrong, assuming you actually assigned the other variables corrrectly. However, there could be a variety of game object related behavior.

Is the ground tag applied to the game obejct that you think your runner is colliding with? If not, it won't jump.

Is your mass for the jumper's rigidbody very high? With the default of 1, it jumps pretty high, but could not get the right amount of force if it was a larger mass.

How To Jump in Unity, 93% OFF Make Your First Game Course ▻ https://www.udemy.com/make-your-​first-game Duration: 7:43 Posted: 31 Jul 2017 As in the example, use a Vector3.Up multiplied by the force of your jump. You can include this code in the FidexUpdate function. If the jump key is down (http://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html), then AddForce to the player.

it seems to be correct in your code but don't know why not jumping. BTW, you can try with this code just without AddForce and changing the checking you are using.

if (Input.GetButtonDown("Jump") && OnGround)
{
    rBody.velocity = new Vector2(rBody.velocity.x, jumpSpeed);
}

Make sure it is under your Update method coz Input calls in Update method. If your 'OnGround' Layer check is perfect it should work.

Better Jumping in Unity With Four Lines of Code, Eliminate the low-gravity feeling of a physics based jump with four is for figuring this out Duration: 12:47 Posted: 20 Mar 2017 Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.

Unity3D - Player Jump (with Double Jump), Whenever I do my double jump, I can't jump again. Any solution or is the tutorial Duration: 5:47 Posted: 1 Sep 2017 Mix Play all Mix - Board To Bits Games YouTube HOLD JUMP KEY TO JUMP HIGHER - 2D PLATFORMER CONTROLLER - UNITY TUTORIAL - Duration: 9:01. Blackthornprod 111,564 views

Unity - C# Simple Jump Script (Tutorial), In this tutorial I teach you how to make your player jump by adding upward force using a Duration: 6:46 Posted: 13 Apr 2018 Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.

Simple Jump in Unity 2D (Unity Tutorial for Beginners), Let's make a Simple Character Jump in Unity 2D using Unity Physics will learn Duration: 17:48 Posted: 14 Apr 2019 (need to jump around 110cm fast). What I have now work for movement but jump is more like jetpack, it does slowly speed upwards. I would be glad if somebody would be so kind and helped me with jump issue as I am not programmer, just need this for level design setting/browsing. Would prefer posting whole functioning code for the same reason.

Comments
  • It's difficult to say what is wrong. The code looks correct. Some things to check: The Rigidbody must not be kinematic and active. What is its mass? Perhaps the characters position is set from other code? What happens if you increase the force?
  • Did you try to set breakpoints and debug?
  • OnCollisionEnter starts with a capital O otherwise it is never called! could this be the issue?
  • OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider, if you dont have a collider/rigidbody attached to the collision object it wont thrigger.
  • As a sidenote, it's recommended to make all Input calls within the flow of the Update method. See the Input documentation for more information.
  • Thanks for your reply. It really can't jump: I have checked the position, also everything is okay with the rigid body, it is not kinematic.
  • Thanks for your reply. I have corrected OnCollisionEnter Syntax. The tag for the ground is correctly assigned. I have assigned a tag for each tile which I am instantiating and making infinite ground if there can be a problem, I don't know. Object mass is one, and the object itself is very small.