private void FixedUpdate()
{
Jump();
}
float kdjump = (float)1;
float time = 0;
public void Jump()
{
time += Time.deltaTime;
if (time >= kdjump)
{
if (IsGround())
{
Debug.Log(“Jump”);
rg.AddForce(new Vector2(0, PowerJump), ForceMode2D.Impulse);
time = 0;
}
}
}
Here’s the jump code. With PowerJump = 15, the object flies up the size of one block (the first screen). With PowerJump = 30, the object flies up almost as many as 5 blocks (second screen).
Use this instead :
rg.velocity = new Vector3(0f, PowerJump, 0f);
ForceMode2D.Impulse
adds a sudden force to the player, so initially the force will be very high but it will reduce at a not so uniform rate