# Two Basic Physic Questions (Gravity and Jumping)

So… I’ve never really had this problem with the 3D games I’ve made, because gravity was supposed to make you fall to the ground… and ultimately… stay there, however for the game I’m working on now that’s not the case.

The goal is actually to… NOT hit the bottom. Think of concepts such as the infamously hated Flappy Bird, or Jetpack Joyride. Where you are constantly falling down, but have to stay up.

Here’s my problem.

Gravity: It seems like gravity constantly increases. Like it’s a multiplier. The longer you fall, the faster you fall. This is unacceptable for my game style. I need to fall down at a constant rate… While… I’m not “Jumping” or… “Propelling” or… “Flying upwards” or whatever.

Jumping: I tried using the following code… but nothing happens when I jump. Literally. I mean any debug calls I make in the method go off, but the character does not raise, or do anything besides continue to fall to his immediate death.

``````rigidbody.AddForce(Vector3.up * forceApplied);
``````

First 2D game, sorry if the questions are a little strange, I’ve been working with 3D games where gravity does not apply, recently.

Really confused on what I’m doing wrong here.

using UnityEngine;
using System.Collections;

``````public class characterController : MonoBehaviour
{
public float jumpPower = 2.0f;
public float gravity = 9.81f;
public float velocityChange = 2.0f;
private float forceApplied = 0.0f;
private Rigidbody2D r = null;

void Start()
{
r = GetComponent<Rigidbody2D>();
}

void FixedUpdate()
{
if (Input.GetButtonDown("Jump"))
{
r.velocity = new Vector2(r.velocity.x, Mathf.Sqrt(2 * jumpPower * gravity));
}
float velocity = Mathf.Max((gravity - r.velocity.y), 0.0f);
forceApplied = (gravity - velocity);
forceApplied = Mathf.Clamp(forceApplied, -gravity, gravity);