So i just wanna know how i could go about controlling the gravity for the rigidbodys addforce function ? like when i jump the player reaches the end of his jump and like floats for maybe 0.2 seconds, then drops down again, it feels very floaty and unrealistic (not that the game is supposed to be realistic, but u get me), and he also shoots up in the air whenever i double jump.
Ive tried setting the gravity in the physics2D project settings, from the default -9.81 to like -15 - -19. But it feels like its too much. The box collider on my character is 1 unit tall, and the objects in the scene are two units tall, if that helps. my question is: how do i make the jump so that it feels more realistic, so that the character falls directly to the ground after reaching the jump limit, and doesnt float for 0.2 seconds, and also doesnt shoot straigt up in the air when i doublejump, but jumps with same force as the first jump.
My movement code is:
void FixedUpdate()
{
var absVelY = Mathf.Abs (rigidbody2D.velocity.y);
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
if (controller.moving.x != 0)
{
transform.localScale = new Vector3 (controller.moving.x > 0? 1 : -1, 1, 1);
animator.SetInteger ("AnimState", 1);
} else
{
animator.SetInteger ("AnimState", 0);
}
if (absVelY < 0.02f)
{
grounded = true;
}
else
{
grounded = false;
}
if (grounded)
{
jumpCount = 0;
}
if (jumpCount < maxJump)
{
if (Input.GetKeyDown ("space"))
{
rigidbody2D.AddForce (new Vector2 (0, jumpForce));
jumpCount++;
}
}
}