Script is:
public class PlayerMovement : MonoBehaviour
{
public CharacterController2D controller;
float horizontalMove = 0f;
public float runSpeed = 40f;
public float jumpForce = 1000f;
public Rigidbody2D rb;
public Vector2 jumpHeight;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
}
void FixedUpdate ()
{
controller.Move(horizontalMove * Time.fixedDeltaTime, false, false);
if(Input.GetKey(KeyCode.Space)) {
rb.AddForce(jumpHeight, ForceMode2D.Impulse);
}
}
}
It have a movement script, it working by CharacterController script, which I took from Internet. I don’t have problem with it. But jumping… I don’t have any errors, but when I pressing Space, my character is start flying.
P.S. English - not my native language, so sorry for mistakes in sentences.